testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

Running Cucumber Features in Parallel from TestRunner #1748

Closed rahulkamboj14 closed 6 years ago

rahulkamboj14 commented 6 years ago

TestNG Version

6.14.2

Expected behavior

testng should create a thread for every feature in the test runner so that all the features can be run parallelly

Actual behavior

features are not running in parallel and running one after another.

Is the issue reproductible on runner?

When I am running the cucumber test from testng.xml, scenarios are not executed in parallel. Scenarios are executed one after another. I am using the threads and parallel configuration in testng.xml file and using the surefire plugin for running the features. In the Testruuner I have metioned the website folder where I have got multiple feature file. So when I run the test using Maven it always executes the feature files one after another and not in parallel. Check the below configuration:

Test case sample

Surefire Plugin configuration from pom.xml:

<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-surefire-plugin</artifactId>
<version></version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>Testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>

Testng.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Local" parallel="tests" thread-count="5" verbose="2">
<listeners>
<listener class-name="driver.LocalWebDriverListener" />
<listener class-name="reports.ExecutionListeners" />
</listeners>
<test name="Test in Chrome">
<parameter name="browserName" value="chrome" />
<classes>
<class name="testRunner.Windows7Chrome60" />
</classes>
</test>
</suite>

TestRunner file in which Website is the folder where I have got multiple features:

@CucumberOptions(
strict = true, 
monochrome = true, 
features = {"src/main/java/features/Website"},
dryRun = false, 
glue = {"driver", "stepDefination", "testRunner" }, 
tags = {},
plugin = { "pretty",  "json:target/RawJsonResult/Windows7Chrome60.json"}
)
public class Windows7Chrome60 extends AbstractTestNGCucumberTests{
}
krmahadevan commented 6 years ago

This is not an issue with TestNG. AbstractTestNGCucumberTests is a class that is not being owned by the TestNG codebase. You would need to be filing a bug in cucumber-jvm project.

On a side note, You can still try and toggle the parallel attribute to true by building a TestNG listener which implements org.testng.IAnnotationTransformer2 and within its transform(IDataProviderAnnotation annotation, Method method) you can try toggling the parallel attribute of the @DataProvider annotation, since the internal implementation relies on a data provider.

PS: I am not sure if Cucumber reports are thread safe and as such your mileage may vary.

prashantsaraogi commented 5 years ago

is this issue closed? Can anyone please share the version of TestNG

krmahadevan commented 5 years ago

Please refer to my previous comment. This is not a TestNG issue. So no code change was done and issue was closed.

prashantsaraogi commented 5 years ago

Thanks for confirmation!!! I use AbstractTestNGCucumberTests to run test parallel, I am expecting the creation of runner dynamically.