Reputation: 650
When we run cucumber tests on forked JVM processes, each test is isolated pretty much immediately, so if we try to use any sort of @before or @after it will run on every single jvm instance, and yes we could setup here, it will be executed on every process pointlessly...
How can we get in before the forked JVM processes and execute a single method even to validate the test run before proceeding etc?
The same should go for a run once after all tests on all JVM's have been executed.
Is there a simple solution for this?
Upvotes: 0
Views: 446
Reputation: 650
Answer: I ended up writing a single individual test which validated the run and did all runOnce type code, telling surefire to run this test phase before the main one so the main test only continued when validation was a pass.
other alternatives: maven plugin which I also wrote does the same kind of idea. other alternatives: get the JVM forked number from maven and set it as a system property, do some action(s) where the forked number == 1 for example and pause /sleep the other JVMs until the validation has been done, then continue (will require an external source to be updated, like a properties file with:
canContinue=0
to poll on each JVM until it is 1 to continue
Upvotes: 1
Reputation: 5908
Take a look of gherkin using qaf. Where you can have different listeners including one that run before suite execution. You also can write method with @BeforeSuite
annotation.
Upvotes: 0