How to use a forked vm for each cucumber scenario/feature using maven-surefire-plugin

Viewed 18

To tests some scenario i need to run my full application. i need each test to run in a forked vm in order to have a "clean" vm. look easy enough with the following:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M7</version>
    <configuration>
        <forkCount>1</forkCount>
        <reuseForks>false</reuseForks>
        <parallel>all</parallel>
    </configuration>
</plugin>

i added a log to check if the vm is actually forked or not: log.info("PID:{}", ProcessHandle.current().pid()); for standard junit tests, this is working well. However for cucumber tests, they are all showing the same PID. it looks like all the cucumber tests defined from the same runner are considered like a single test for this forked vm feature

this is how i defines the cucumber runner:


    @RunWith(Cucumber.class)
    @CucumberOptions(
        features = "src/test/resources/features/",
        plugin = {"json:report.json"},
        snippets = CAMELCASE
    )
    public class RunCucumber {
    }

anyone know how to use forked vm with cucumber tests?

if i create a dedicated runner per scenario it works, but this is far from being ideal. Thanks

0 Answers
Related