Open BartVanRaemdonck opened 4 years ago
@BeforeAll and @AfterAll have no equivalent in Cucumber.
Is there an alternative? I want to close my local Browserstack proxy after my tests.
So I should quit Serenity BDD and Cucumber just because it doesn't support @AfterAll ?
@AfterAll annotations have a number of potential issues in multi-threaded contexts (how do you know when all the features have finished?). I would probabl use a shutdown hook (https://www.geeksforgeeks.org/jvm-shutdown-hook-java/)
Ok, thanks @wakaleo . For now I worked with this code:
@Before
public void setup() {
Runtime.getRuntime().addShutdownHook(new Thread(){
@Override
public void run(){
try {
System.out.println("Artificial After ALL");
stopBrowserStackLocal();
} catch (Exception e) {
e.printStackTrace();
}
}
});
Maybe in the future the following can be developed in Serenity? https://medium.com/@pauloloboneto/cucumber-java-annotation-afterall-e-beforeall-c2bfea0e2203
I still have a problem because I want to use Browserstack. And Browserstack uses a session for every test. I have to use BrowserMobProxy and Browserstack local to run some network tests. U need to initialize browserstack local at driver level for every session, so I can't use Serenity? Because I initialize my driver, at the start of the fist test with my provided driver, after the first test the browserstack session is closed, so the best solution here is to close the browserstack local instance, close the browsermob proxy instance and startup new ones, but for that the happen I just start a new driver instance? And that isn't possible with Serenity?
I tried it like this, but it doesn't work. Also with the JUnit4 BeforeClass and Afterclass.