Hi,
JC Oosthuizen wrote:
Hi All,
I have a question regarding the use of onSetupBeforeTransaction. This will be called before the transaction is created and will therefore not be rolled back when the test is done. I know one can implement the onTearDownAfterTransaction to remove the data added in onSetupBeforeTransaction.
I created a POJO with a unique field, which causes the tests to fail as the object is not properly removed between tests in one test case.
I moved the code from onSetupBeforeTransaction to onSetupInTransaction which solved my problem as the object will be removed when the transaction is rolled back.
Why is the setup done before the transaction and not in the transaction. Doing it in the transaction should give more isolated test cases and should be better.
Regards,
JC Oosthuizen
I noticed the same in an *ActionTest generated using the appfuse maven plugin.
The test fails as the object saved in onSetupBeforeTransaction gets committed to database, while its correct position should be in onSetupInTransaction as you say.
I've opened an issue:
http://issues.appfuse.org/browse/APF-1082Marcello