hwellmann / jeeunit

Automatically exported from code.google.com/p/jeeunit
Other
0 stars 1 forks source link

Feature request, clear out database on each test. #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Slapping on transactional annotation is not always enough.
1. Annotate a test with @Transactional
2. Test a piece of code that calls persist and flush
3. The persisted object is never rolled back, as it is flushed.

This is a problem as it will lead to test pollution. Thats why im suggesting a 
feature that clears out the database before each test run.

Original issue reported on code.google.com by k...@heldig.org on 6 Feb 2012 at 8:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
em.flush() just causes SQL statements to be sent to the database. It does not 
commit the current transaction.

To convince yourself, run com.googlecode.jeeunit.example.test.AuthorTest after 
adding em.flush() to LibraryService.createAuthor().

All this assumes you're running with container-managed transactions. 

So it's really hard to tell what's causing the behaviour you've observed. Could 
you try to provide a self-contained test case? 

Original comment by hwellman...@gmail.com on 9 Feb 2012 at 9:47