cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

Feature Request :TestNG support to run feature files in parallel(like Junit 4) #2479

Closed surajgupta7175 closed 2 years ago

surajgupta7175 commented 2 years ago

Is your feature request related to a problem? Please describe. With Version 4 Selenium and cucumber-jvm. We cannot run feature files parallely using TestNG . The same feature is available with Junit

Currently when we run 2 threads, Scenario 1 & 2 present in same feature file gets executed Problem - Scenario 2 is dependent on Scenario 1 to complete

Under maven-surefireplugin


<properties>
        <property>
        <name>dataproviderthreadcount</name>
        <value>2</value>
        </property>
</properties>
<parallel>classes</parallel> 
<useUnlimitedThreads>true</useUnlimitedThreads> 

<perCoreThreadCount>true</perCoreThreadCount>
<includes> 
    <include>Runner Path to be added</include>
</includes>

Article used to setup - https://cucumber.io/docs/guides/parallel-execution/?sbsearch=parallel

mpkorstanje commented 2 years ago

The execution unit of Cucumber is the Scenario. So you should make each scenario independent from the other scenarios. While JUnit 4 would only execute scenarios in parallel this was due to limitations of JUnit 4 rather then an intentional feature. When using JUnit 5, scenarios are executed in parallel.

surajgupta7175 commented 2 years ago

@mpkorstanje How to manage testdata when one testcase is creating testdata and other is using it in same feature file. Can't this be a feature?

mpkorstanje commented 2 years ago

No. But have a look at:

https://specflow.org/challenges/chain-of-dependent-scenarios/

You may also find other suggestions on google. It's a fairly common problem that happens when test scripts are converted 1-to-1 into features. The general idea is that you try to have each scenario start from a clean slate where possible (i.e. a new user, a new account ect). This may require improving the test-ability of the system overall.