I\'m using cucumber-jvm in my integration tests and I need to execute some code after all scenarios are finished, just once.
After reading carefully som
Probably a better way would be to use a build tool, like Ant, Maven or Gradle for set-up and tear-down actions, which are part of integration tests.
When using Maven Fail Safe Plug-in, for setting up integration tests. There is the phase pre-integration-test, which is typically used for setting up the database and launch the web-container. Then the integration-tests are run (phase integration-test). And afterwards the phase post-integration-test is run, for shutting down and closing / removing / cleaning up things.
INFO In case the Cucumber tests are run through JUnit, the following might also be worth considering
In case it is simpler, smaller set up stuff, you can have a look at the JUnit @BeforeClass and @AfterClass. Or implement a JUnit @ClassRule, which has it's own before() and after() methods.
@ClassRule
public static ExternalResource resource = new ExternalResource() {
@Override
protected void before() throws Throwable {
myServer.connect();
}
@Override
protected void after() {
myServer.disconnect();
}
};