In my project I have to do some repository setup before all tests. This is done using some tricky static rules. However I\'ve got no clue how to do clean up after all the te
I recommend to use org.junit.runner.notification.RunListener, example:
public class TestListener extends RunListener {
@Override
public void testRunStarted(Description description) throws Exception {
// Called before any tests have been run.
}
@Override
public void testRunFinished(Result result) throws Exception {
// Called when all tests have finished
}
}
Read more directly in JUnit java doc. You can use that even with Maven's surefire (unit tests) plugin or failsafe plugin (integration tests) by adding following code into plugin configuration:
listener
com.innovatrics.afismq.it.TestListener