Search code examples
javaunit-testingdbunit

DBUnit setup method not called?


I'm using DBUnit for testing DAOs implemented with Hibernate and Spring. I put a breakpoint in the setup code of DBUnit and I see that the corresponding methods are never called. I need to initialize my database following the CLEAN_INSERT scheme but the setup method (overriden from TestCase) is never called.

Any idea?

EDIT: I saw in the maven dependency graph that DBunit 2.4.8 (last version) depends on JUnit 3.8.2?! Is DBUnit compatible with newer versions of JUnit (4.9)?

Thanks


Solution

  • If you're using JUnit 4, you shouldn't be extending from TestCase any more. Put the code from the example in http://www.dbunit.org/howto.html#noextend in your own method. You can call it anything you want as long as you annotate it with @org.junit.Before.