I am trying to use dbunit to test the database of the system. Since several testcases can be tested using same dataset, I want to init the dataset once for all of them. But I also use @AutoWire of spring to init those db connection parameter.
I tried to use @BeforeClass and @AfterClass to setup the db. But turns out the @Autowire happens when class get initiated(not seems not work for auto wire static members).
So wondering is there any other way i can setup/tear down the db dataset before/after all the testcases?
I found one elegant solution:
How to allow instance methods to run as JUnit BeforeClass behavior
This post basically explained a way to change unittest runner to trigger the events. And for spring, the AbstractTestExecutionListener can be used as well