Avi
Avi

Reputation: 29

How to control the order of scenarios execution when running in parallel mode - Cucumber Junit5

I have the below use case. I have multiple feature files each feature file consists of scenarios as listed below.

Feature1:

@capture Scenario C1:

@capture Scenario C2: . . . @capture Scenario Cn:

@batchJob Scenario B1:

@validation Scenario V1:

@validation Scenario V2: . . . @validation Scenario V3:

I have a dependency that @batchJob has to execute after all @captures are done and @validation should execute @batchjob is done. I have handled it in the Hooks and they work fine.

However, when running in parallel, I see that scenarios are assigned to threads. So I want to understand in what order the scenarios get assigned to thread. What I have observed, every time the last scenario of each feature file is getting started, so 10 threads popped up and assigned to @validation scenarios only as each file's last scenario is tagged with that (which will be held in indefinite state because of my dependency, as I don't have other threads to run for @capture scenarios).

So I'm trying to understand what is the default order of the scenarios execution.

Is there any way to control the order either by pom.xml using profiles or some other method?

here are the dependencies I am using

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.9.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>7.11.1</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit-platform-engine</artifactId>
        <version>7.11.1</version>
    </dependency>
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>5.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>3.9.6</version>
    </dependency>

And this is what I have in junit-platform.properties file

"cucumber.execution.parallel.enabled=true"

The basic recommendation is to run the mvn commands for each tags separately. But I want to get these tags executed in order during "mvn clean install" itself. So I came across profiles that to be added to pom.xml and use maven antrun plugin to execute the phases. However, it is not working.

Upvotes: 0

Views: 117

Answers (0)

Related Questions