Cucumber-jvm - Thread created per scenario, despite fixed.parallelism being set

29 Views Asked by At

Using cucumber-java 7.90 and JUnit 5, setting my junit-platform.properties file to the below, I would expect only 5 threads to be created.

cucumber.execution.parallel.enabled=true
cucumber.execution.execution-mode.feature=concurrent
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=5

However, I have noticed that a thread gets created per scenario. I'm wondering if anyone has experienced this before? I was under the impression that the above fixes the threads to 5. A bit more detail on my setup and where it's failing. I want to create a driver per thread so in each StepDef file, I have a SharedDriver call in the constructor. e.g.

public LoginTest(SharedDriver driver) {}

SharedDriver contains a mechanism to check if this thread has a driver or not. First scenario, should always be null (getDriver returns a ThreadLocal entry), so then I create and add a driver in place. Second scenario on that thread, getDriver should not be null and so is skipped and the scenario continues

public SharedDriver() {
    if (DriverFactory.getDriver() == null) {
        // Create Driver here and assign it to a ThreadLocal List.
    }
}

It appears that every scenario gets it's own thread so if I have 12 scenarios, that's 12 threads and then 12 drivers. this appears to be an issue with the properties file to me, as I said I thought the fixed.parallelism would fix the threads created to whatever I set it to

Any more details required, please let me know. More info

  • Java 17
  • mvn test to trigger runs
0

There are 0 best solutions below