title: How to setup/teardown dbunit dataset without using static @BeforeClass
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>So wondering is there any other way i can setup/tear down the db dataset before/after all the testcases?</p>
  
  <p>I found one elegant solution: </p>
  
  <p><a href="http://saltnlight5.blogspot.com/2012/09/enhancing-spring-test-framework-with.html" rel="nofollow">How to allow instance methods to run as JUnit BeforeClass behavior</a></p>
  
  <p>This post basically explained a way to change unittest runner to trigger the events.
  And for spring, the AbstractTestExecutionListener can be used as well</p>