3

Here is my cuke runner. I am trying to use inbuilt parallelism built in cucumber-jvm 4.0.0 by overriding dataprovider method. I see that my scenarios are invoked in parallel however the thread count defaults to 10 always. I tried executing with --threads options as state in GitHub but it doesnt work.

mvn test -Dcucumber.options="--tags @test --threads 3"
mvn test -Dcucumber.options="--threads 3"

Tried both but still 10 threads are spawned by default. What am i missing here? I know there are others ways to achieve parallelism in cukes using temyers plugin or qaf 3rd party plugin. But my question is very specific to native parallel support of cucumber-jvm 4.0.0 What am i missing here in my CLI cucumber options?

   package cuke.runner;

    import org.testng.annotations.DataProvider;

    import cucumber.api.CucumberOptions;
    import cucumber.api.testng.AbstractTestNGCucumberTests;

    @CucumberOptions(features= {"src/test/resources/features"},glue="com/sd")
    public class TestRunner extends AbstractTestNGCucumberTests{
        @Override
        @DataProvider(parallel=true)
        public Object[][] scenarios() {
            return super.scenarios();
        }
    }
Bhuvanesh Mani
  • 1,394
  • 14
  • 23
  • U need to use the Main class contained in the cucumber.api.cli package if u want to use the 'threads' option. The command would be something like - Main.main(new String[]{ “–threads”, “4”, “-g”, “stepdef”, “src/test/resources/features/parallel/”});. No runner is required. https://github.com/cucumber/cucumber-jvm/blob/v4.0.0/core/src/main/resources/cucumber/api/cli/USAGE.txt – Grasshopper Feb 13 '19 at 08:13
  • 2
    If u want to use a testng runner for parallel running refer to this - https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html. Especially the parallel running part. U have to assign the 'dataproviderthreadcount' property to the number u want. Defaults to 10, -> http://testng.org/doc/documentation-main.html#parameters-dataproviders. – Grasshopper Feb 13 '19 at 09:17
  • Can you please elaborate? I am invoking my tests from command line using mvn test as i said earlier. How can i control the thread count from -Dcucumber.options? I have already tried specifying data-provider-thread-count in my suite.xml and it didnt work. – Bhuvanesh Mani Feb 13 '19 at 09:33
  • I dont want to run my cukes in plain class under some main method to pass argument values through cucumber.api.cli.Main options. Looks like i did not understand cucumber-jvm parallel execution where i need help. I must trigger my tests using mvn test and need to control number of threads, it can be jvm argument along with mvn test or testsuite.xml or surefire-plugin configuration, but none of these working out. i am missing something! – Bhuvanesh Mani Feb 13 '19 at 11:18
  • 1
    Finally, I found out the solution. Root cause was maven-surefire-plugin bug in version 2.12.4 which was throwing cast exception when I try to pass the property dataproviderthreadcount in configuration. I just changed the version to 3.0.0.-M3 and it all worked like charm! However i still need help on controlling the thread from mvn test "--threads 3" cucumber options – Bhuvanesh Mani Feb 13 '19 at 19:23
  • 1
    As I explained above the threads option only works with the "Main" class. It will not work through maven anyway u execute it. – Grasshopper Feb 14 '19 at 10:52

2 Answers2

0

The default thread count of the dataprovider in parallel mode is 10. To change this the dataproviderthreadcount property needs to be added to the configuration section of the Surefire or Failsafe plugin in the POM.

<configuration>
    <properties>
        <property>
            <name>dataproviderthreadcount</name>
            <value>20</value>
        </property>
    </properties>
</configuration>
Marit
  • 2,399
  • 18
  • 27
  • Thanks but this doesnt help my question as i already have this solution. My question is very specific about setting thread count from command line not through pom.xml – Bhuvanesh Mani Jun 10 '19 at 14:14
0

pass arguments -Ddataproviderthreadcount=1000 in command line

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
sankardev51
  • 37
  • 1
  • 6