Home > database >  Limit the number of scenario to run in parallel - testng - cuccumber
Limit the number of scenario to run in parallel - testng - cuccumber

Time:10-09

Thanks in advance.

I had create an UI BDD framework and using testNG as a runner. Problem I am facing is , I have 3 feature file with in total 12 scenario so far , so when I run in parallel , 12 browser open up , because of which I am getting timeout exception , I tried to search entire www , and done changes in my pom file but still same.

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.version}</version>
            <configuration>
                <includes>
                    <include>**/ParallelRun.java</include>
                </includes>
                <parallel>classes</parallel>
                <threadCount>4</threadCount>
                <perCoreThreadCount>false</perCoreThreadCount>
                <forkCount>3</forkCount>
            </configuration>
        </plugin>

Runner Class

public class ParallelRun extends AbstractTestNGCucumberTests {
@Override
@DataProvider(parallel = true)
public Object[][] scenarios() {
    return super.scenarios();
}

}

CodePudding user response:

I believe that the core of your problem is not in surefire config but in your tests.

Anyway I would rework your configuration to be (which has to limit your threads to 3)

<configuration>
    <includes>
        <include>**/ParallelRun.java</include>
    </includes>
    <properties>
        <property>
            <name>dataproviderthreadcount</name>
            <value>3</value>
        </property>
    </properties>
</configuration>

According to cucumber documentation you need to have parallel=classes only if you have several test runners.

Forks are also not applicable here. According to surefire plugin doc forks with parallel=classes do not make sense since forks themselves process classes in parallel.

CodePudding user response:

Scenarios will be executed in parallel, so please decrease your thread count to 1.

<threadCount>1</threadCount>

if you are using TDD, use thread count.
if you are using BDD via cucumber file, do not use thread count - set as 1 thread count.

  • Related