How to execute cucumber feature file parallel

Multi tool use
Multi tool use





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







7















I have below feature files (Separate feature files) in src/test/resources/feature/ and I would like to run them in parallel. Like: One feature file has to execute in chrome and another one has to execute in firefox as mentioned @Tags name.



Feature: Refund item

@chrome
Scenario: Jeff returns a faulty microwave
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100

Feature: Refund Money

@firefox
Scenario: Jeff returns the money
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100


Can somebody assist me to achieve this.I'm using cucumber-java 1.2.2 version, and AbstractTestNGCucumberTests using as runner. Also, let me know how can I create a Test Runner dynamically by using feature files and make them run in parallel.










share|improve this question

























  • what are you trying to achieve here? What is the end goal?

    – k1133
    Dec 8 '16 at 10:13











  • I would like to execute the feature files in parallel with different browsers. I have a application where i need to do browser compatibility testing. So far we had sequence execution to validate the browser compatibility. I just heard about cucumber-jvm-parallel plugin but not much aware how to implement it. And heard that It will create a runners in dynamically and help us to do parallel execution in scenario or feature wise.

    – ArrchanaMohan
    Dec 8 '16 at 13:41











  • You can try maven and surefire plugin. It will use multiple threads which will run each available runner individually. Google cucmber java maven parallel. Used to have the link for the article but somehow got deleted

    – Grasshopper
    Dec 8 '16 at 15:02













  • Thanks Grasshopper.

    – ArrchanaMohan
    Dec 9 '16 at 4:20




















7















I have below feature files (Separate feature files) in src/test/resources/feature/ and I would like to run them in parallel. Like: One feature file has to execute in chrome and another one has to execute in firefox as mentioned @Tags name.



Feature: Refund item

@chrome
Scenario: Jeff returns a faulty microwave
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100

Feature: Refund Money

@firefox
Scenario: Jeff returns the money
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100


Can somebody assist me to achieve this.I'm using cucumber-java 1.2.2 version, and AbstractTestNGCucumberTests using as runner. Also, let me know how can I create a Test Runner dynamically by using feature files and make them run in parallel.










share|improve this question

























  • what are you trying to achieve here? What is the end goal?

    – k1133
    Dec 8 '16 at 10:13











  • I would like to execute the feature files in parallel with different browsers. I have a application where i need to do browser compatibility testing. So far we had sequence execution to validate the browser compatibility. I just heard about cucumber-jvm-parallel plugin but not much aware how to implement it. And heard that It will create a runners in dynamically and help us to do parallel execution in scenario or feature wise.

    – ArrchanaMohan
    Dec 8 '16 at 13:41











  • You can try maven and surefire plugin. It will use multiple threads which will run each available runner individually. Google cucmber java maven parallel. Used to have the link for the article but somehow got deleted

    – Grasshopper
    Dec 8 '16 at 15:02













  • Thanks Grasshopper.

    – ArrchanaMohan
    Dec 9 '16 at 4:20
















7












7








7


5






I have below feature files (Separate feature files) in src/test/resources/feature/ and I would like to run them in parallel. Like: One feature file has to execute in chrome and another one has to execute in firefox as mentioned @Tags name.



Feature: Refund item

@chrome
Scenario: Jeff returns a faulty microwave
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100

Feature: Refund Money

@firefox
Scenario: Jeff returns the money
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100


Can somebody assist me to achieve this.I'm using cucumber-java 1.2.2 version, and AbstractTestNGCucumberTests using as runner. Also, let me know how can I create a Test Runner dynamically by using feature files and make them run in parallel.










share|improve this question
















I have below feature files (Separate feature files) in src/test/resources/feature/ and I would like to run them in parallel. Like: One feature file has to execute in chrome and another one has to execute in firefox as mentioned @Tags name.



Feature: Refund item

@chrome
Scenario: Jeff returns a faulty microwave
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100

Feature: Refund Money

@firefox
Scenario: Jeff returns the money
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100


Can somebody assist me to achieve this.I'm using cucumber-java 1.2.2 version, and AbstractTestNGCucumberTests using as runner. Also, let me know how can I create a Test Runner dynamically by using feature files and make them run in parallel.







java cucumber testng cucumber-jvm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 8 '16 at 7:39







ArrchanaMohan

















asked Dec 8 '16 at 7:33









ArrchanaMohanArrchanaMohan

4961420




4961420













  • what are you trying to achieve here? What is the end goal?

    – k1133
    Dec 8 '16 at 10:13











  • I would like to execute the feature files in parallel with different browsers. I have a application where i need to do browser compatibility testing. So far we had sequence execution to validate the browser compatibility. I just heard about cucumber-jvm-parallel plugin but not much aware how to implement it. And heard that It will create a runners in dynamically and help us to do parallel execution in scenario or feature wise.

    – ArrchanaMohan
    Dec 8 '16 at 13:41











  • You can try maven and surefire plugin. It will use multiple threads which will run each available runner individually. Google cucmber java maven parallel. Used to have the link for the article but somehow got deleted

    – Grasshopper
    Dec 8 '16 at 15:02













  • Thanks Grasshopper.

    – ArrchanaMohan
    Dec 9 '16 at 4:20





















  • what are you trying to achieve here? What is the end goal?

    – k1133
    Dec 8 '16 at 10:13











  • I would like to execute the feature files in parallel with different browsers. I have a application where i need to do browser compatibility testing. So far we had sequence execution to validate the browser compatibility. I just heard about cucumber-jvm-parallel plugin but not much aware how to implement it. And heard that It will create a runners in dynamically and help us to do parallel execution in scenario or feature wise.

    – ArrchanaMohan
    Dec 8 '16 at 13:41











  • You can try maven and surefire plugin. It will use multiple threads which will run each available runner individually. Google cucmber java maven parallel. Used to have the link for the article but somehow got deleted

    – Grasshopper
    Dec 8 '16 at 15:02













  • Thanks Grasshopper.

    – ArrchanaMohan
    Dec 9 '16 at 4:20



















what are you trying to achieve here? What is the end goal?

– k1133
Dec 8 '16 at 10:13





what are you trying to achieve here? What is the end goal?

– k1133
Dec 8 '16 at 10:13













I would like to execute the feature files in parallel with different browsers. I have a application where i need to do browser compatibility testing. So far we had sequence execution to validate the browser compatibility. I just heard about cucumber-jvm-parallel plugin but not much aware how to implement it. And heard that It will create a runners in dynamically and help us to do parallel execution in scenario or feature wise.

– ArrchanaMohan
Dec 8 '16 at 13:41





I would like to execute the feature files in parallel with different browsers. I have a application where i need to do browser compatibility testing. So far we had sequence execution to validate the browser compatibility. I just heard about cucumber-jvm-parallel plugin but not much aware how to implement it. And heard that It will create a runners in dynamically and help us to do parallel execution in scenario or feature wise.

– ArrchanaMohan
Dec 8 '16 at 13:41













You can try maven and surefire plugin. It will use multiple threads which will run each available runner individually. Google cucmber java maven parallel. Used to have the link for the article but somehow got deleted

– Grasshopper
Dec 8 '16 at 15:02







You can try maven and surefire plugin. It will use multiple threads which will run each available runner individually. Google cucmber java maven parallel. Used to have the link for the article but somehow got deleted

– Grasshopper
Dec 8 '16 at 15:02















Thanks Grasshopper.

– ArrchanaMohan
Dec 9 '16 at 4:20







Thanks Grasshopper.

– ArrchanaMohan
Dec 9 '16 at 4:20














4 Answers
4






active

oldest

votes


















12














Update: 4.0.0 version is available at maven central repository with bunch of changes.for more details go here.



Update: 2.2.0 version is available at maven central repository.



You can use opensource plugin cucumber-jvm-parallel-plugin which has many advantages over existing solutions. Available at maven repository



   <dependency>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>2.1.0</version>
</dependency>




  1. First you need to add this plugin with required configuration in your project pom file.



    <plugin>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>2.1.0</version>
    <executions>
    <execution>
    <id>generateRunners</id>
    <phase>generate-test-sources</phase>
    <goals>
    <goal>generateRunners</goal>
    </goals>
    <configuration>
    <!-- Mandatory -->
    <!-- comma separated list of package names to scan for glue code -->
    <glue>foo, bar</glue>
    <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
    <!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->
    <featuresDirectory>src/test/resources/features/</featuresDirectory>
    <!-- Directory where the cucumber report files shall be written -->
    <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
    <!-- comma separated list of output formats json,html,rerun.txt -->
    <format>json</format>
    <!-- CucumberOptions.strict property -->
    <strict>true</strict>
    <!-- CucumberOptions.monochrome property -->
    <monochrome>true</monochrome>
    <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
    <tags></tags>
    <!-- If set to true, only feature files containing the required tags shall be generated. -->
    <filterFeaturesByTags>false</filterFeaturesByTags>
    <!-- Generate TestNG runners instead of default JUnit ones. -->
    <useTestNG>false</useTestNG>
    <!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->
    <namingScheme>simple</namingScheme>
    <!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
    <namingPattern>Parallel{c}IT</namingPattern>
    <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
    <parallelScheme>SCENARIO</parallelScheme>
    <!-- This is optional, required only if you want to specify a custom template for the generated sources (this is a relative path) -->
    <customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>
    </configuration>
    </execution>
    </executions>
    </plugin>



  2. Now add below plugin just below above plugin which will invoke runner classes generated by above plugin



        <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19</version>
    <configuration>
    <forkCount>5</forkCount>
    <reuseForks>true</reuseForks>
    <includes>
    <include>**/*IT.class</include>
    </includes>
    </configuration>
    </plugin>


  3. Above two plugins will do magic for cucumber test running in parallel (provided you machine also have advanced hardware support).


  4. Strictly provided <forkCount>n</forkCount> here 'n' is directly proportional to 1) Advanced Hardware support and 2) you available nodes i.e. registered browser instances to HUB.



  5. One major and most important changes is your WebDriver class must be SHARED and you should not implement driver.quit() method, as closing is take care by shutdown hook.



    import cucumber.api.Scenario;
    import cucumber.api.java.After;
    import cucumber.api.java.Before;
    import org.openqa.selenium.OutputType;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebDriverException;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.events.EventFiringWebDriver;

    public class SharedDriver extends EventFiringWebDriver {
    private static WebDriver REAL_DRIVER = null;



    private static final Thread CLOSE_THREAD = new Thread() {
    @Override
    public void run() {
    REAL_DRIVER.close();
    }
    };

    static {
    Runtime.getRuntime().addShutdownHook(CLOSE_THREAD);
    }

    public SharedDriver() {
    super(CreateDriver());
    }

    public static WebDriver CreateDriver() {
    WebDriver webDriver;
    if (REAL_DRIVER == null)
    webDriver = new FirefoxDriver();
    setWebDriver(webDriver);
    return webDriver;
    }

    public static void setWebDriver(WebDriver webDriver) {
    this.REAL_DRIVER = webDriver;
    }

    public static WebDriver getWebDriver() {
    return this.REAL_DRIVER;
    }

    @Override
    public void close() {
    if (Thread.currentThread() != CLOSE_THREAD) {
    throw new UnsupportedOperationException("You shouldn't close this WebDriver. It's shared and will close when the JVM exits.");
    }
    super.close();
    }

    @Before
    public void deleteAllCookies() {
    manage().deleteAllCookies();
    }

    @After
    public void embedScreenshot(Scenario scenario) {
    try {
    byte screenshot = getScreenshotAs(OutputType.BYTES);
    scenario.embed(screenshot, "image/png");
    } catch (WebDriverException somePlatformsDontSupportScreenshots) {
    System.err.println(somePlatformsDontSupportScreenshots.getMessage());
    }
    }
    }



  6. Considering you want to execute more than 50 threads i.e. same no of browser instances are registered to HUB but Hub will die if it doesn't get enough memory therefore to avoid this critical situation you should start hub with -DPOOL_MAX=512 (or larger) as stated in grid2 documentation.



    Really large (>50 node) Hub installations may need to increase the jetty threads by setting -DPOOL_MAX=512 (or larger) on the java command line.



    java -jar selenium-server-standalone-<version>.jar -role hub -DPOOL_MAX=512








share|improve this answer


























  • Many thanks sugat Mankar for your inputs. Its very useful.

    – ArrchanaMohan
    Dec 14 '16 at 5:53











  • I don't really get. Why do I need to add cucumber-jvm-parallel-plugin if it is still needed to specify forks in maven-surefire-plugin?

    – olyv
    Nov 27 '17 at 7:38











  • @olyv this plugin only generate runner classes, depending on tags you passed. Execution is not purpose of this plugin and hence it is done by surefire plugin.

    – Sugat Mankar
    May 14 '18 at 11:49











  • @SugatMankar o, makes sense to me

    – olyv
    May 14 '18 at 13:48











  • @SugatMankar How it differs from Cucable plugin?

    – Ashok kumar Ganesan
    Jul 2 '18 at 4:45



















3














If all you are expecting is to be able to run multiple features in parallel, then you can try doing the following :




  • Duplicate the class AbstractTestNGCucumberTests in your test project and set the attribute parallel=true to the @DataProvider annotated method.


Since the default dataprovider-thread-count from TestNG is 10 and now that you have instructed TestNG to run features in parallel, you should start seeing your feature files get executed in parallel.



But I understand that Cucumber reporting is inherently not thread safe, so your reports may appear garbled.






share|improve this answer
























  • Thanks for your inputs krishnana mahadevan.

    – ArrchanaMohan
    Dec 12 '16 at 5:45











  • thanks! works for me. only need to add testNG runner dependency implementation("io.cucumber:cucumber-testng:4.0.0")

    – ludenus
    Oct 2 '18 at 15:47



















3














Cucumber does not support parallel execution out of the box.
I've tried, but it is not friendly.




  1. We have to use maven's capability to invoke it in parallel. Refer link

  2. Also there is a github project which uses custom plugin to execute in parallel.
    Refer cucumber-jvm-parallel-plugin






share|improve this answer


























  • Thanks bharath kumar. It helps a lot.

    – ArrchanaMohan
    Dec 12 '16 at 5:44











  • This seems to be the way to collate parallel cucumber json output files into one report: github.com/rajatthareja/ReportBuilder . Also, for Ruby, putting parallel_cucumber module in a Rakefile seems to run things in parallel without a problem.

    – djangofan
    Feb 28 '17 at 2:33













  • How to generate consolidated report for Cucumber java. Because I get separate folder for each feature file like 1, 2, 3 , 4. Each will contains the js and html file. How to consolidate everything.

    – Ashok kumar Ganesan
    Jul 3 '18 at 10:00











  • @Ashokkumar You'll have to write an implementation to merge the reports. I'd suggest to generate Cucumber JSON output file and have your implementation parse JSON files to generate a single report.

    – Bharath Kumar
    Jul 12 '18 at 9:43













  • Parallel execution is supported natively since v4.0.0

    – mpkorstanje
    Jan 18 at 11:43



















0














To take maximum advantage of TestNG you can use Testng's third party extension QAF framework. It supports multiple bdd syntax including gherkin using GherkinFactory.
While using BDD with QAF, you can take advantage of each TestNG features, including data-providers, parallel execution configuration in different ways (groups/tests/methods), TestNG listeners.



QAF considers each scenario as TestNG test and Scenario Outline as TestNG data-driven test. As qaf provides driver management and resource management in-built, you don't need to write single line of code for driver management or resource management. All you need to do is create TestNG xml configuration file as per your requirement either to run parallel methods (scenarios) or groups or xml test on one or more browser.



It enables different possible configuration combinations. Below is the xml configuration to address this question which will run scenarios in two browsers and in parallel. You can configure number of threads for each browser as standard TestNG xml configuration as well.



<suite name="AUT Test Automation" verbose="0"  parallel="tests">
<test name="Test-on-chrome">
<parameter name="scenario.file.loc" value="resources/features" />
<parameter name="driver.name" value="chromeDriver" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>

<test name="Test-on-FF">
<parameter name="scenario.file.loc" value="resources/features" />
<parameter name="driver.name" value="firefoxDriver" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
</suite>


More over the latest BDDTestFactory2 supports syntax that is derived from QAF BDD, Jbehave and gherkin. It supports meta-data from qaf bdd as tags and examples from gherkin. You can take benefit of inbuilt data-providers to provide test data in XML/JSON/CSV/EXCEL/DB using meta-data in BDD.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41034116%2fhow-to-execute-cucumber-feature-file-parallel%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    12














    Update: 4.0.0 version is available at maven central repository with bunch of changes.for more details go here.



    Update: 2.2.0 version is available at maven central repository.



    You can use opensource plugin cucumber-jvm-parallel-plugin which has many advantages over existing solutions. Available at maven repository



       <dependency>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>2.1.0</version>
    </dependency>




    1. First you need to add this plugin with required configuration in your project pom file.



      <plugin>
      <groupId>com.github.temyers</groupId>
      <artifactId>cucumber-jvm-parallel-plugin</artifactId>
      <version>2.1.0</version>
      <executions>
      <execution>
      <id>generateRunners</id>
      <phase>generate-test-sources</phase>
      <goals>
      <goal>generateRunners</goal>
      </goals>
      <configuration>
      <!-- Mandatory -->
      <!-- comma separated list of package names to scan for glue code -->
      <glue>foo, bar</glue>
      <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
      <!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->
      <featuresDirectory>src/test/resources/features/</featuresDirectory>
      <!-- Directory where the cucumber report files shall be written -->
      <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
      <!-- comma separated list of output formats json,html,rerun.txt -->
      <format>json</format>
      <!-- CucumberOptions.strict property -->
      <strict>true</strict>
      <!-- CucumberOptions.monochrome property -->
      <monochrome>true</monochrome>
      <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
      <tags></tags>
      <!-- If set to true, only feature files containing the required tags shall be generated. -->
      <filterFeaturesByTags>false</filterFeaturesByTags>
      <!-- Generate TestNG runners instead of default JUnit ones. -->
      <useTestNG>false</useTestNG>
      <!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->
      <namingScheme>simple</namingScheme>
      <!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
      <namingPattern>Parallel{c}IT</namingPattern>
      <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
      <parallelScheme>SCENARIO</parallelScheme>
      <!-- This is optional, required only if you want to specify a custom template for the generated sources (this is a relative path) -->
      <customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>
      </configuration>
      </execution>
      </executions>
      </plugin>



    2. Now add below plugin just below above plugin which will invoke runner classes generated by above plugin



          <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.19</version>
      <configuration>
      <forkCount>5</forkCount>
      <reuseForks>true</reuseForks>
      <includes>
      <include>**/*IT.class</include>
      </includes>
      </configuration>
      </plugin>


    3. Above two plugins will do magic for cucumber test running in parallel (provided you machine also have advanced hardware support).


    4. Strictly provided <forkCount>n</forkCount> here 'n' is directly proportional to 1) Advanced Hardware support and 2) you available nodes i.e. registered browser instances to HUB.



    5. One major and most important changes is your WebDriver class must be SHARED and you should not implement driver.quit() method, as closing is take care by shutdown hook.



      import cucumber.api.Scenario;
      import cucumber.api.java.After;
      import cucumber.api.java.Before;
      import org.openqa.selenium.OutputType;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebDriverException;
      import org.openqa.selenium.firefox.FirefoxDriver;
      import org.openqa.selenium.support.events.EventFiringWebDriver;

      public class SharedDriver extends EventFiringWebDriver {
      private static WebDriver REAL_DRIVER = null;



      private static final Thread CLOSE_THREAD = new Thread() {
      @Override
      public void run() {
      REAL_DRIVER.close();
      }
      };

      static {
      Runtime.getRuntime().addShutdownHook(CLOSE_THREAD);
      }

      public SharedDriver() {
      super(CreateDriver());
      }

      public static WebDriver CreateDriver() {
      WebDriver webDriver;
      if (REAL_DRIVER == null)
      webDriver = new FirefoxDriver();
      setWebDriver(webDriver);
      return webDriver;
      }

      public static void setWebDriver(WebDriver webDriver) {
      this.REAL_DRIVER = webDriver;
      }

      public static WebDriver getWebDriver() {
      return this.REAL_DRIVER;
      }

      @Override
      public void close() {
      if (Thread.currentThread() != CLOSE_THREAD) {
      throw new UnsupportedOperationException("You shouldn't close this WebDriver. It's shared and will close when the JVM exits.");
      }
      super.close();
      }

      @Before
      public void deleteAllCookies() {
      manage().deleteAllCookies();
      }

      @After
      public void embedScreenshot(Scenario scenario) {
      try {
      byte screenshot = getScreenshotAs(OutputType.BYTES);
      scenario.embed(screenshot, "image/png");
      } catch (WebDriverException somePlatformsDontSupportScreenshots) {
      System.err.println(somePlatformsDontSupportScreenshots.getMessage());
      }
      }
      }



    6. Considering you want to execute more than 50 threads i.e. same no of browser instances are registered to HUB but Hub will die if it doesn't get enough memory therefore to avoid this critical situation you should start hub with -DPOOL_MAX=512 (or larger) as stated in grid2 documentation.



      Really large (>50 node) Hub installations may need to increase the jetty threads by setting -DPOOL_MAX=512 (or larger) on the java command line.



      java -jar selenium-server-standalone-<version>.jar -role hub -DPOOL_MAX=512








    share|improve this answer


























    • Many thanks sugat Mankar for your inputs. Its very useful.

      – ArrchanaMohan
      Dec 14 '16 at 5:53











    • I don't really get. Why do I need to add cucumber-jvm-parallel-plugin if it is still needed to specify forks in maven-surefire-plugin?

      – olyv
      Nov 27 '17 at 7:38











    • @olyv this plugin only generate runner classes, depending on tags you passed. Execution is not purpose of this plugin and hence it is done by surefire plugin.

      – Sugat Mankar
      May 14 '18 at 11:49











    • @SugatMankar o, makes sense to me

      – olyv
      May 14 '18 at 13:48











    • @SugatMankar How it differs from Cucable plugin?

      – Ashok kumar Ganesan
      Jul 2 '18 at 4:45
















    12














    Update: 4.0.0 version is available at maven central repository with bunch of changes.for more details go here.



    Update: 2.2.0 version is available at maven central repository.



    You can use opensource plugin cucumber-jvm-parallel-plugin which has many advantages over existing solutions. Available at maven repository



       <dependency>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>2.1.0</version>
    </dependency>




    1. First you need to add this plugin with required configuration in your project pom file.



      <plugin>
      <groupId>com.github.temyers</groupId>
      <artifactId>cucumber-jvm-parallel-plugin</artifactId>
      <version>2.1.0</version>
      <executions>
      <execution>
      <id>generateRunners</id>
      <phase>generate-test-sources</phase>
      <goals>
      <goal>generateRunners</goal>
      </goals>
      <configuration>
      <!-- Mandatory -->
      <!-- comma separated list of package names to scan for glue code -->
      <glue>foo, bar</glue>
      <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
      <!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->
      <featuresDirectory>src/test/resources/features/</featuresDirectory>
      <!-- Directory where the cucumber report files shall be written -->
      <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
      <!-- comma separated list of output formats json,html,rerun.txt -->
      <format>json</format>
      <!-- CucumberOptions.strict property -->
      <strict>true</strict>
      <!-- CucumberOptions.monochrome property -->
      <monochrome>true</monochrome>
      <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
      <tags></tags>
      <!-- If set to true, only feature files containing the required tags shall be generated. -->
      <filterFeaturesByTags>false</filterFeaturesByTags>
      <!-- Generate TestNG runners instead of default JUnit ones. -->
      <useTestNG>false</useTestNG>
      <!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->
      <namingScheme>simple</namingScheme>
      <!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
      <namingPattern>Parallel{c}IT</namingPattern>
      <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
      <parallelScheme>SCENARIO</parallelScheme>
      <!-- This is optional, required only if you want to specify a custom template for the generated sources (this is a relative path) -->
      <customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>
      </configuration>
      </execution>
      </executions>
      </plugin>



    2. Now add below plugin just below above plugin which will invoke runner classes generated by above plugin



          <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.19</version>
      <configuration>
      <forkCount>5</forkCount>
      <reuseForks>true</reuseForks>
      <includes>
      <include>**/*IT.class</include>
      </includes>
      </configuration>
      </plugin>


    3. Above two plugins will do magic for cucumber test running in parallel (provided you machine also have advanced hardware support).


    4. Strictly provided <forkCount>n</forkCount> here 'n' is directly proportional to 1) Advanced Hardware support and 2) you available nodes i.e. registered browser instances to HUB.



    5. One major and most important changes is your WebDriver class must be SHARED and you should not implement driver.quit() method, as closing is take care by shutdown hook.



      import cucumber.api.Scenario;
      import cucumber.api.java.After;
      import cucumber.api.java.Before;
      import org.openqa.selenium.OutputType;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebDriverException;
      import org.openqa.selenium.firefox.FirefoxDriver;
      import org.openqa.selenium.support.events.EventFiringWebDriver;

      public class SharedDriver extends EventFiringWebDriver {
      private static WebDriver REAL_DRIVER = null;



      private static final Thread CLOSE_THREAD = new Thread() {
      @Override
      public void run() {
      REAL_DRIVER.close();
      }
      };

      static {
      Runtime.getRuntime().addShutdownHook(CLOSE_THREAD);
      }

      public SharedDriver() {
      super(CreateDriver());
      }

      public static WebDriver CreateDriver() {
      WebDriver webDriver;
      if (REAL_DRIVER == null)
      webDriver = new FirefoxDriver();
      setWebDriver(webDriver);
      return webDriver;
      }

      public static void setWebDriver(WebDriver webDriver) {
      this.REAL_DRIVER = webDriver;
      }

      public static WebDriver getWebDriver() {
      return this.REAL_DRIVER;
      }

      @Override
      public void close() {
      if (Thread.currentThread() != CLOSE_THREAD) {
      throw new UnsupportedOperationException("You shouldn't close this WebDriver. It's shared and will close when the JVM exits.");
      }
      super.close();
      }

      @Before
      public void deleteAllCookies() {
      manage().deleteAllCookies();
      }

      @After
      public void embedScreenshot(Scenario scenario) {
      try {
      byte screenshot = getScreenshotAs(OutputType.BYTES);
      scenario.embed(screenshot, "image/png");
      } catch (WebDriverException somePlatformsDontSupportScreenshots) {
      System.err.println(somePlatformsDontSupportScreenshots.getMessage());
      }
      }
      }



    6. Considering you want to execute more than 50 threads i.e. same no of browser instances are registered to HUB but Hub will die if it doesn't get enough memory therefore to avoid this critical situation you should start hub with -DPOOL_MAX=512 (or larger) as stated in grid2 documentation.



      Really large (>50 node) Hub installations may need to increase the jetty threads by setting -DPOOL_MAX=512 (or larger) on the java command line.



      java -jar selenium-server-standalone-<version>.jar -role hub -DPOOL_MAX=512








    share|improve this answer


























    • Many thanks sugat Mankar for your inputs. Its very useful.

      – ArrchanaMohan
      Dec 14 '16 at 5:53











    • I don't really get. Why do I need to add cucumber-jvm-parallel-plugin if it is still needed to specify forks in maven-surefire-plugin?

      – olyv
      Nov 27 '17 at 7:38











    • @olyv this plugin only generate runner classes, depending on tags you passed. Execution is not purpose of this plugin and hence it is done by surefire plugin.

      – Sugat Mankar
      May 14 '18 at 11:49











    • @SugatMankar o, makes sense to me

      – olyv
      May 14 '18 at 13:48











    • @SugatMankar How it differs from Cucable plugin?

      – Ashok kumar Ganesan
      Jul 2 '18 at 4:45














    12












    12








    12







    Update: 4.0.0 version is available at maven central repository with bunch of changes.for more details go here.



    Update: 2.2.0 version is available at maven central repository.



    You can use opensource plugin cucumber-jvm-parallel-plugin which has many advantages over existing solutions. Available at maven repository



       <dependency>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>2.1.0</version>
    </dependency>




    1. First you need to add this plugin with required configuration in your project pom file.



      <plugin>
      <groupId>com.github.temyers</groupId>
      <artifactId>cucumber-jvm-parallel-plugin</artifactId>
      <version>2.1.0</version>
      <executions>
      <execution>
      <id>generateRunners</id>
      <phase>generate-test-sources</phase>
      <goals>
      <goal>generateRunners</goal>
      </goals>
      <configuration>
      <!-- Mandatory -->
      <!-- comma separated list of package names to scan for glue code -->
      <glue>foo, bar</glue>
      <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
      <!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->
      <featuresDirectory>src/test/resources/features/</featuresDirectory>
      <!-- Directory where the cucumber report files shall be written -->
      <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
      <!-- comma separated list of output formats json,html,rerun.txt -->
      <format>json</format>
      <!-- CucumberOptions.strict property -->
      <strict>true</strict>
      <!-- CucumberOptions.monochrome property -->
      <monochrome>true</monochrome>
      <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
      <tags></tags>
      <!-- If set to true, only feature files containing the required tags shall be generated. -->
      <filterFeaturesByTags>false</filterFeaturesByTags>
      <!-- Generate TestNG runners instead of default JUnit ones. -->
      <useTestNG>false</useTestNG>
      <!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->
      <namingScheme>simple</namingScheme>
      <!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
      <namingPattern>Parallel{c}IT</namingPattern>
      <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
      <parallelScheme>SCENARIO</parallelScheme>
      <!-- This is optional, required only if you want to specify a custom template for the generated sources (this is a relative path) -->
      <customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>
      </configuration>
      </execution>
      </executions>
      </plugin>



    2. Now add below plugin just below above plugin which will invoke runner classes generated by above plugin



          <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.19</version>
      <configuration>
      <forkCount>5</forkCount>
      <reuseForks>true</reuseForks>
      <includes>
      <include>**/*IT.class</include>
      </includes>
      </configuration>
      </plugin>


    3. Above two plugins will do magic for cucumber test running in parallel (provided you machine also have advanced hardware support).


    4. Strictly provided <forkCount>n</forkCount> here 'n' is directly proportional to 1) Advanced Hardware support and 2) you available nodes i.e. registered browser instances to HUB.



    5. One major and most important changes is your WebDriver class must be SHARED and you should not implement driver.quit() method, as closing is take care by shutdown hook.



      import cucumber.api.Scenario;
      import cucumber.api.java.After;
      import cucumber.api.java.Before;
      import org.openqa.selenium.OutputType;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebDriverException;
      import org.openqa.selenium.firefox.FirefoxDriver;
      import org.openqa.selenium.support.events.EventFiringWebDriver;

      public class SharedDriver extends EventFiringWebDriver {
      private static WebDriver REAL_DRIVER = null;



      private static final Thread CLOSE_THREAD = new Thread() {
      @Override
      public void run() {
      REAL_DRIVER.close();
      }
      };

      static {
      Runtime.getRuntime().addShutdownHook(CLOSE_THREAD);
      }

      public SharedDriver() {
      super(CreateDriver());
      }

      public static WebDriver CreateDriver() {
      WebDriver webDriver;
      if (REAL_DRIVER == null)
      webDriver = new FirefoxDriver();
      setWebDriver(webDriver);
      return webDriver;
      }

      public static void setWebDriver(WebDriver webDriver) {
      this.REAL_DRIVER = webDriver;
      }

      public static WebDriver getWebDriver() {
      return this.REAL_DRIVER;
      }

      @Override
      public void close() {
      if (Thread.currentThread() != CLOSE_THREAD) {
      throw new UnsupportedOperationException("You shouldn't close this WebDriver. It's shared and will close when the JVM exits.");
      }
      super.close();
      }

      @Before
      public void deleteAllCookies() {
      manage().deleteAllCookies();
      }

      @After
      public void embedScreenshot(Scenario scenario) {
      try {
      byte screenshot = getScreenshotAs(OutputType.BYTES);
      scenario.embed(screenshot, "image/png");
      } catch (WebDriverException somePlatformsDontSupportScreenshots) {
      System.err.println(somePlatformsDontSupportScreenshots.getMessage());
      }
      }
      }



    6. Considering you want to execute more than 50 threads i.e. same no of browser instances are registered to HUB but Hub will die if it doesn't get enough memory therefore to avoid this critical situation you should start hub with -DPOOL_MAX=512 (or larger) as stated in grid2 documentation.



      Really large (>50 node) Hub installations may need to increase the jetty threads by setting -DPOOL_MAX=512 (or larger) on the java command line.



      java -jar selenium-server-standalone-<version>.jar -role hub -DPOOL_MAX=512








    share|improve this answer















    Update: 4.0.0 version is available at maven central repository with bunch of changes.for more details go here.



    Update: 2.2.0 version is available at maven central repository.



    You can use opensource plugin cucumber-jvm-parallel-plugin which has many advantages over existing solutions. Available at maven repository



       <dependency>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>2.1.0</version>
    </dependency>




    1. First you need to add this plugin with required configuration in your project pom file.



      <plugin>
      <groupId>com.github.temyers</groupId>
      <artifactId>cucumber-jvm-parallel-plugin</artifactId>
      <version>2.1.0</version>
      <executions>
      <execution>
      <id>generateRunners</id>
      <phase>generate-test-sources</phase>
      <goals>
      <goal>generateRunners</goal>
      </goals>
      <configuration>
      <!-- Mandatory -->
      <!-- comma separated list of package names to scan for glue code -->
      <glue>foo, bar</glue>
      <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
      <!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->
      <featuresDirectory>src/test/resources/features/</featuresDirectory>
      <!-- Directory where the cucumber report files shall be written -->
      <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
      <!-- comma separated list of output formats json,html,rerun.txt -->
      <format>json</format>
      <!-- CucumberOptions.strict property -->
      <strict>true</strict>
      <!-- CucumberOptions.monochrome property -->
      <monochrome>true</monochrome>
      <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
      <tags></tags>
      <!-- If set to true, only feature files containing the required tags shall be generated. -->
      <filterFeaturesByTags>false</filterFeaturesByTags>
      <!-- Generate TestNG runners instead of default JUnit ones. -->
      <useTestNG>false</useTestNG>
      <!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->
      <namingScheme>simple</namingScheme>
      <!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
      <namingPattern>Parallel{c}IT</namingPattern>
      <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
      <parallelScheme>SCENARIO</parallelScheme>
      <!-- This is optional, required only if you want to specify a custom template for the generated sources (this is a relative path) -->
      <customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>
      </configuration>
      </execution>
      </executions>
      </plugin>



    2. Now add below plugin just below above plugin which will invoke runner classes generated by above plugin



          <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.19</version>
      <configuration>
      <forkCount>5</forkCount>
      <reuseForks>true</reuseForks>
      <includes>
      <include>**/*IT.class</include>
      </includes>
      </configuration>
      </plugin>


    3. Above two plugins will do magic for cucumber test running in parallel (provided you machine also have advanced hardware support).


    4. Strictly provided <forkCount>n</forkCount> here 'n' is directly proportional to 1) Advanced Hardware support and 2) you available nodes i.e. registered browser instances to HUB.



    5. One major and most important changes is your WebDriver class must be SHARED and you should not implement driver.quit() method, as closing is take care by shutdown hook.



      import cucumber.api.Scenario;
      import cucumber.api.java.After;
      import cucumber.api.java.Before;
      import org.openqa.selenium.OutputType;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebDriverException;
      import org.openqa.selenium.firefox.FirefoxDriver;
      import org.openqa.selenium.support.events.EventFiringWebDriver;

      public class SharedDriver extends EventFiringWebDriver {
      private static WebDriver REAL_DRIVER = null;



      private static final Thread CLOSE_THREAD = new Thread() {
      @Override
      public void run() {
      REAL_DRIVER.close();
      }
      };

      static {
      Runtime.getRuntime().addShutdownHook(CLOSE_THREAD);
      }

      public SharedDriver() {
      super(CreateDriver());
      }

      public static WebDriver CreateDriver() {
      WebDriver webDriver;
      if (REAL_DRIVER == null)
      webDriver = new FirefoxDriver();
      setWebDriver(webDriver);
      return webDriver;
      }

      public static void setWebDriver(WebDriver webDriver) {
      this.REAL_DRIVER = webDriver;
      }

      public static WebDriver getWebDriver() {
      return this.REAL_DRIVER;
      }

      @Override
      public void close() {
      if (Thread.currentThread() != CLOSE_THREAD) {
      throw new UnsupportedOperationException("You shouldn't close this WebDriver. It's shared and will close when the JVM exits.");
      }
      super.close();
      }

      @Before
      public void deleteAllCookies() {
      manage().deleteAllCookies();
      }

      @After
      public void embedScreenshot(Scenario scenario) {
      try {
      byte screenshot = getScreenshotAs(OutputType.BYTES);
      scenario.embed(screenshot, "image/png");
      } catch (WebDriverException somePlatformsDontSupportScreenshots) {
      System.err.println(somePlatformsDontSupportScreenshots.getMessage());
      }
      }
      }



    6. Considering you want to execute more than 50 threads i.e. same no of browser instances are registered to HUB but Hub will die if it doesn't get enough memory therefore to avoid this critical situation you should start hub with -DPOOL_MAX=512 (or larger) as stated in grid2 documentation.



      Really large (>50 node) Hub installations may need to increase the jetty threads by setting -DPOOL_MAX=512 (or larger) on the java command line.



      java -jar selenium-server-standalone-<version>.jar -role hub -DPOOL_MAX=512









    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 20 '17 at 9:20

























    answered Dec 12 '16 at 11:43









    Sugat MankarSugat Mankar

    400114




    400114













    • Many thanks sugat Mankar for your inputs. Its very useful.

      – ArrchanaMohan
      Dec 14 '16 at 5:53











    • I don't really get. Why do I need to add cucumber-jvm-parallel-plugin if it is still needed to specify forks in maven-surefire-plugin?

      – olyv
      Nov 27 '17 at 7:38











    • @olyv this plugin only generate runner classes, depending on tags you passed. Execution is not purpose of this plugin and hence it is done by surefire plugin.

      – Sugat Mankar
      May 14 '18 at 11:49











    • @SugatMankar o, makes sense to me

      – olyv
      May 14 '18 at 13:48











    • @SugatMankar How it differs from Cucable plugin?

      – Ashok kumar Ganesan
      Jul 2 '18 at 4:45



















    • Many thanks sugat Mankar for your inputs. Its very useful.

      – ArrchanaMohan
      Dec 14 '16 at 5:53











    • I don't really get. Why do I need to add cucumber-jvm-parallel-plugin if it is still needed to specify forks in maven-surefire-plugin?

      – olyv
      Nov 27 '17 at 7:38











    • @olyv this plugin only generate runner classes, depending on tags you passed. Execution is not purpose of this plugin and hence it is done by surefire plugin.

      – Sugat Mankar
      May 14 '18 at 11:49











    • @SugatMankar o, makes sense to me

      – olyv
      May 14 '18 at 13:48











    • @SugatMankar How it differs from Cucable plugin?

      – Ashok kumar Ganesan
      Jul 2 '18 at 4:45

















    Many thanks sugat Mankar for your inputs. Its very useful.

    – ArrchanaMohan
    Dec 14 '16 at 5:53





    Many thanks sugat Mankar for your inputs. Its very useful.

    – ArrchanaMohan
    Dec 14 '16 at 5:53













    I don't really get. Why do I need to add cucumber-jvm-parallel-plugin if it is still needed to specify forks in maven-surefire-plugin?

    – olyv
    Nov 27 '17 at 7:38





    I don't really get. Why do I need to add cucumber-jvm-parallel-plugin if it is still needed to specify forks in maven-surefire-plugin?

    – olyv
    Nov 27 '17 at 7:38













    @olyv this plugin only generate runner classes, depending on tags you passed. Execution is not purpose of this plugin and hence it is done by surefire plugin.

    – Sugat Mankar
    May 14 '18 at 11:49





    @olyv this plugin only generate runner classes, depending on tags you passed. Execution is not purpose of this plugin and hence it is done by surefire plugin.

    – Sugat Mankar
    May 14 '18 at 11:49













    @SugatMankar o, makes sense to me

    – olyv
    May 14 '18 at 13:48





    @SugatMankar o, makes sense to me

    – olyv
    May 14 '18 at 13:48













    @SugatMankar How it differs from Cucable plugin?

    – Ashok kumar Ganesan
    Jul 2 '18 at 4:45





    @SugatMankar How it differs from Cucable plugin?

    – Ashok kumar Ganesan
    Jul 2 '18 at 4:45













    3














    If all you are expecting is to be able to run multiple features in parallel, then you can try doing the following :




    • Duplicate the class AbstractTestNGCucumberTests in your test project and set the attribute parallel=true to the @DataProvider annotated method.


    Since the default dataprovider-thread-count from TestNG is 10 and now that you have instructed TestNG to run features in parallel, you should start seeing your feature files get executed in parallel.



    But I understand that Cucumber reporting is inherently not thread safe, so your reports may appear garbled.






    share|improve this answer
























    • Thanks for your inputs krishnana mahadevan.

      – ArrchanaMohan
      Dec 12 '16 at 5:45











    • thanks! works for me. only need to add testNG runner dependency implementation("io.cucumber:cucumber-testng:4.0.0")

      – ludenus
      Oct 2 '18 at 15:47
















    3














    If all you are expecting is to be able to run multiple features in parallel, then you can try doing the following :




    • Duplicate the class AbstractTestNGCucumberTests in your test project and set the attribute parallel=true to the @DataProvider annotated method.


    Since the default dataprovider-thread-count from TestNG is 10 and now that you have instructed TestNG to run features in parallel, you should start seeing your feature files get executed in parallel.



    But I understand that Cucumber reporting is inherently not thread safe, so your reports may appear garbled.






    share|improve this answer
























    • Thanks for your inputs krishnana mahadevan.

      – ArrchanaMohan
      Dec 12 '16 at 5:45











    • thanks! works for me. only need to add testNG runner dependency implementation("io.cucumber:cucumber-testng:4.0.0")

      – ludenus
      Oct 2 '18 at 15:47














    3












    3








    3







    If all you are expecting is to be able to run multiple features in parallel, then you can try doing the following :




    • Duplicate the class AbstractTestNGCucumberTests in your test project and set the attribute parallel=true to the @DataProvider annotated method.


    Since the default dataprovider-thread-count from TestNG is 10 and now that you have instructed TestNG to run features in parallel, you should start seeing your feature files get executed in parallel.



    But I understand that Cucumber reporting is inherently not thread safe, so your reports may appear garbled.






    share|improve this answer













    If all you are expecting is to be able to run multiple features in parallel, then you can try doing the following :




    • Duplicate the class AbstractTestNGCucumberTests in your test project and set the attribute parallel=true to the @DataProvider annotated method.


    Since the default dataprovider-thread-count from TestNG is 10 and now that you have instructed TestNG to run features in parallel, you should start seeing your feature files get executed in parallel.



    But I understand that Cucumber reporting is inherently not thread safe, so your reports may appear garbled.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 9 '16 at 17:51









    Krishnan MahadevanKrishnan Mahadevan

    9,06331744




    9,06331744













    • Thanks for your inputs krishnana mahadevan.

      – ArrchanaMohan
      Dec 12 '16 at 5:45











    • thanks! works for me. only need to add testNG runner dependency implementation("io.cucumber:cucumber-testng:4.0.0")

      – ludenus
      Oct 2 '18 at 15:47



















    • Thanks for your inputs krishnana mahadevan.

      – ArrchanaMohan
      Dec 12 '16 at 5:45











    • thanks! works for me. only need to add testNG runner dependency implementation("io.cucumber:cucumber-testng:4.0.0")

      – ludenus
      Oct 2 '18 at 15:47

















    Thanks for your inputs krishnana mahadevan.

    – ArrchanaMohan
    Dec 12 '16 at 5:45





    Thanks for your inputs krishnana mahadevan.

    – ArrchanaMohan
    Dec 12 '16 at 5:45













    thanks! works for me. only need to add testNG runner dependency implementation("io.cucumber:cucumber-testng:4.0.0")

    – ludenus
    Oct 2 '18 at 15:47





    thanks! works for me. only need to add testNG runner dependency implementation("io.cucumber:cucumber-testng:4.0.0")

    – ludenus
    Oct 2 '18 at 15:47











    3














    Cucumber does not support parallel execution out of the box.
    I've tried, but it is not friendly.




    1. We have to use maven's capability to invoke it in parallel. Refer link

    2. Also there is a github project which uses custom plugin to execute in parallel.
      Refer cucumber-jvm-parallel-plugin






    share|improve this answer


























    • Thanks bharath kumar. It helps a lot.

      – ArrchanaMohan
      Dec 12 '16 at 5:44











    • This seems to be the way to collate parallel cucumber json output files into one report: github.com/rajatthareja/ReportBuilder . Also, for Ruby, putting parallel_cucumber module in a Rakefile seems to run things in parallel without a problem.

      – djangofan
      Feb 28 '17 at 2:33













    • How to generate consolidated report for Cucumber java. Because I get separate folder for each feature file like 1, 2, 3 , 4. Each will contains the js and html file. How to consolidate everything.

      – Ashok kumar Ganesan
      Jul 3 '18 at 10:00











    • @Ashokkumar You'll have to write an implementation to merge the reports. I'd suggest to generate Cucumber JSON output file and have your implementation parse JSON files to generate a single report.

      – Bharath Kumar
      Jul 12 '18 at 9:43













    • Parallel execution is supported natively since v4.0.0

      – mpkorstanje
      Jan 18 at 11:43
















    3














    Cucumber does not support parallel execution out of the box.
    I've tried, but it is not friendly.




    1. We have to use maven's capability to invoke it in parallel. Refer link

    2. Also there is a github project which uses custom plugin to execute in parallel.
      Refer cucumber-jvm-parallel-plugin






    share|improve this answer


























    • Thanks bharath kumar. It helps a lot.

      – ArrchanaMohan
      Dec 12 '16 at 5:44











    • This seems to be the way to collate parallel cucumber json output files into one report: github.com/rajatthareja/ReportBuilder . Also, for Ruby, putting parallel_cucumber module in a Rakefile seems to run things in parallel without a problem.

      – djangofan
      Feb 28 '17 at 2:33













    • How to generate consolidated report for Cucumber java. Because I get separate folder for each feature file like 1, 2, 3 , 4. Each will contains the js and html file. How to consolidate everything.

      – Ashok kumar Ganesan
      Jul 3 '18 at 10:00











    • @Ashokkumar You'll have to write an implementation to merge the reports. I'd suggest to generate Cucumber JSON output file and have your implementation parse JSON files to generate a single report.

      – Bharath Kumar
      Jul 12 '18 at 9:43













    • Parallel execution is supported natively since v4.0.0

      – mpkorstanje
      Jan 18 at 11:43














    3












    3








    3







    Cucumber does not support parallel execution out of the box.
    I've tried, but it is not friendly.




    1. We have to use maven's capability to invoke it in parallel. Refer link

    2. Also there is a github project which uses custom plugin to execute in parallel.
      Refer cucumber-jvm-parallel-plugin






    share|improve this answer















    Cucumber does not support parallel execution out of the box.
    I've tried, but it is not friendly.




    1. We have to use maven's capability to invoke it in parallel. Refer link

    2. Also there is a github project which uses custom plugin to execute in parallel.
      Refer cucumber-jvm-parallel-plugin







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 13 '16 at 20:35

























    answered Dec 9 '16 at 6:13









    Bharath KumarBharath Kumar

    755714




    755714













    • Thanks bharath kumar. It helps a lot.

      – ArrchanaMohan
      Dec 12 '16 at 5:44











    • This seems to be the way to collate parallel cucumber json output files into one report: github.com/rajatthareja/ReportBuilder . Also, for Ruby, putting parallel_cucumber module in a Rakefile seems to run things in parallel without a problem.

      – djangofan
      Feb 28 '17 at 2:33













    • How to generate consolidated report for Cucumber java. Because I get separate folder for each feature file like 1, 2, 3 , 4. Each will contains the js and html file. How to consolidate everything.

      – Ashok kumar Ganesan
      Jul 3 '18 at 10:00











    • @Ashokkumar You'll have to write an implementation to merge the reports. I'd suggest to generate Cucumber JSON output file and have your implementation parse JSON files to generate a single report.

      – Bharath Kumar
      Jul 12 '18 at 9:43













    • Parallel execution is supported natively since v4.0.0

      – mpkorstanje
      Jan 18 at 11:43



















    • Thanks bharath kumar. It helps a lot.

      – ArrchanaMohan
      Dec 12 '16 at 5:44











    • This seems to be the way to collate parallel cucumber json output files into one report: github.com/rajatthareja/ReportBuilder . Also, for Ruby, putting parallel_cucumber module in a Rakefile seems to run things in parallel without a problem.

      – djangofan
      Feb 28 '17 at 2:33













    • How to generate consolidated report for Cucumber java. Because I get separate folder for each feature file like 1, 2, 3 , 4. Each will contains the js and html file. How to consolidate everything.

      – Ashok kumar Ganesan
      Jul 3 '18 at 10:00











    • @Ashokkumar You'll have to write an implementation to merge the reports. I'd suggest to generate Cucumber JSON output file and have your implementation parse JSON files to generate a single report.

      – Bharath Kumar
      Jul 12 '18 at 9:43













    • Parallel execution is supported natively since v4.0.0

      – mpkorstanje
      Jan 18 at 11:43

















    Thanks bharath kumar. It helps a lot.

    – ArrchanaMohan
    Dec 12 '16 at 5:44





    Thanks bharath kumar. It helps a lot.

    – ArrchanaMohan
    Dec 12 '16 at 5:44













    This seems to be the way to collate parallel cucumber json output files into one report: github.com/rajatthareja/ReportBuilder . Also, for Ruby, putting parallel_cucumber module in a Rakefile seems to run things in parallel without a problem.

    – djangofan
    Feb 28 '17 at 2:33







    This seems to be the way to collate parallel cucumber json output files into one report: github.com/rajatthareja/ReportBuilder . Also, for Ruby, putting parallel_cucumber module in a Rakefile seems to run things in parallel without a problem.

    – djangofan
    Feb 28 '17 at 2:33















    How to generate consolidated report for Cucumber java. Because I get separate folder for each feature file like 1, 2, 3 , 4. Each will contains the js and html file. How to consolidate everything.

    – Ashok kumar Ganesan
    Jul 3 '18 at 10:00





    How to generate consolidated report for Cucumber java. Because I get separate folder for each feature file like 1, 2, 3 , 4. Each will contains the js and html file. How to consolidate everything.

    – Ashok kumar Ganesan
    Jul 3 '18 at 10:00













    @Ashokkumar You'll have to write an implementation to merge the reports. I'd suggest to generate Cucumber JSON output file and have your implementation parse JSON files to generate a single report.

    – Bharath Kumar
    Jul 12 '18 at 9:43







    @Ashokkumar You'll have to write an implementation to merge the reports. I'd suggest to generate Cucumber JSON output file and have your implementation parse JSON files to generate a single report.

    – Bharath Kumar
    Jul 12 '18 at 9:43















    Parallel execution is supported natively since v4.0.0

    – mpkorstanje
    Jan 18 at 11:43





    Parallel execution is supported natively since v4.0.0

    – mpkorstanje
    Jan 18 at 11:43











    0














    To take maximum advantage of TestNG you can use Testng's third party extension QAF framework. It supports multiple bdd syntax including gherkin using GherkinFactory.
    While using BDD with QAF, you can take advantage of each TestNG features, including data-providers, parallel execution configuration in different ways (groups/tests/methods), TestNG listeners.



    QAF considers each scenario as TestNG test and Scenario Outline as TestNG data-driven test. As qaf provides driver management and resource management in-built, you don't need to write single line of code for driver management or resource management. All you need to do is create TestNG xml configuration file as per your requirement either to run parallel methods (scenarios) or groups or xml test on one or more browser.



    It enables different possible configuration combinations. Below is the xml configuration to address this question which will run scenarios in two browsers and in parallel. You can configure number of threads for each browser as standard TestNG xml configuration as well.



    <suite name="AUT Test Automation" verbose="0"  parallel="tests">
    <test name="Test-on-chrome">
    <parameter name="scenario.file.loc" value="resources/features" />
    <parameter name="driver.name" value="chromeDriver" />
    <classes>
    <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
    </classes>
    </test>

    <test name="Test-on-FF">
    <parameter name="scenario.file.loc" value="resources/features" />
    <parameter name="driver.name" value="firefoxDriver" />
    <classes>
    <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
    </classes>
    </test>
    </suite>


    More over the latest BDDTestFactory2 supports syntax that is derived from QAF BDD, Jbehave and gherkin. It supports meta-data from qaf bdd as tags and examples from gherkin. You can take benefit of inbuilt data-providers to provide test data in XML/JSON/CSV/EXCEL/DB using meta-data in BDD.






    share|improve this answer




























      0














      To take maximum advantage of TestNG you can use Testng's third party extension QAF framework. It supports multiple bdd syntax including gherkin using GherkinFactory.
      While using BDD with QAF, you can take advantage of each TestNG features, including data-providers, parallel execution configuration in different ways (groups/tests/methods), TestNG listeners.



      QAF considers each scenario as TestNG test and Scenario Outline as TestNG data-driven test. As qaf provides driver management and resource management in-built, you don't need to write single line of code for driver management or resource management. All you need to do is create TestNG xml configuration file as per your requirement either to run parallel methods (scenarios) or groups or xml test on one or more browser.



      It enables different possible configuration combinations. Below is the xml configuration to address this question which will run scenarios in two browsers and in parallel. You can configure number of threads for each browser as standard TestNG xml configuration as well.



      <suite name="AUT Test Automation" verbose="0"  parallel="tests">
      <test name="Test-on-chrome">
      <parameter name="scenario.file.loc" value="resources/features" />
      <parameter name="driver.name" value="chromeDriver" />
      <classes>
      <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
      </classes>
      </test>

      <test name="Test-on-FF">
      <parameter name="scenario.file.loc" value="resources/features" />
      <parameter name="driver.name" value="firefoxDriver" />
      <classes>
      <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
      </classes>
      </test>
      </suite>


      More over the latest BDDTestFactory2 supports syntax that is derived from QAF BDD, Jbehave and gherkin. It supports meta-data from qaf bdd as tags and examples from gherkin. You can take benefit of inbuilt data-providers to provide test data in XML/JSON/CSV/EXCEL/DB using meta-data in BDD.






      share|improve this answer


























        0












        0








        0







        To take maximum advantage of TestNG you can use Testng's third party extension QAF framework. It supports multiple bdd syntax including gherkin using GherkinFactory.
        While using BDD with QAF, you can take advantage of each TestNG features, including data-providers, parallel execution configuration in different ways (groups/tests/methods), TestNG listeners.



        QAF considers each scenario as TestNG test and Scenario Outline as TestNG data-driven test. As qaf provides driver management and resource management in-built, you don't need to write single line of code for driver management or resource management. All you need to do is create TestNG xml configuration file as per your requirement either to run parallel methods (scenarios) or groups or xml test on one or more browser.



        It enables different possible configuration combinations. Below is the xml configuration to address this question which will run scenarios in two browsers and in parallel. You can configure number of threads for each browser as standard TestNG xml configuration as well.



        <suite name="AUT Test Automation" verbose="0"  parallel="tests">
        <test name="Test-on-chrome">
        <parameter name="scenario.file.loc" value="resources/features" />
        <parameter name="driver.name" value="chromeDriver" />
        <classes>
        <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
        </classes>
        </test>

        <test name="Test-on-FF">
        <parameter name="scenario.file.loc" value="resources/features" />
        <parameter name="driver.name" value="firefoxDriver" />
        <classes>
        <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
        </classes>
        </test>
        </suite>


        More over the latest BDDTestFactory2 supports syntax that is derived from QAF BDD, Jbehave and gherkin. It supports meta-data from qaf bdd as tags and examples from gherkin. You can take benefit of inbuilt data-providers to provide test data in XML/JSON/CSV/EXCEL/DB using meta-data in BDD.






        share|improve this answer













        To take maximum advantage of TestNG you can use Testng's third party extension QAF framework. It supports multiple bdd syntax including gherkin using GherkinFactory.
        While using BDD with QAF, you can take advantage of each TestNG features, including data-providers, parallel execution configuration in different ways (groups/tests/methods), TestNG listeners.



        QAF considers each scenario as TestNG test and Scenario Outline as TestNG data-driven test. As qaf provides driver management and resource management in-built, you don't need to write single line of code for driver management or resource management. All you need to do is create TestNG xml configuration file as per your requirement either to run parallel methods (scenarios) or groups or xml test on one or more browser.



        It enables different possible configuration combinations. Below is the xml configuration to address this question which will run scenarios in two browsers and in parallel. You can configure number of threads for each browser as standard TestNG xml configuration as well.



        <suite name="AUT Test Automation" verbose="0"  parallel="tests">
        <test name="Test-on-chrome">
        <parameter name="scenario.file.loc" value="resources/features" />
        <parameter name="driver.name" value="chromeDriver" />
        <classes>
        <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
        </classes>
        </test>

        <test name="Test-on-FF">
        <parameter name="scenario.file.loc" value="resources/features" />
        <parameter name="driver.name" value="firefoxDriver" />
        <classes>
        <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
        </classes>
        </test>
        </suite>


        More over the latest BDDTestFactory2 supports syntax that is derived from QAF BDD, Jbehave and gherkin. It supports meta-data from qaf bdd as tags and examples from gherkin. You can take benefit of inbuilt data-providers to provide test data in XML/JSON/CSV/EXCEL/DB using meta-data in BDD.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 21:29









        user861594user861594

        3,05632034




        3,05632034






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41034116%2fhow-to-execute-cucumber-feature-file-parallel%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            si,bithLsQJrOmXmycuxa ZtG GMVwlvNHj 4d6fgHBHAiu0hiUn8ble9RBd3Id2gt75PH6uIqqGJmyljOK Wm3TtjF,KX C
            fJKkiK,tBxJTCHJXhqaCE9POdGblwz H,r7DJtjnXijwLud9e,t9F1HNJ,fV2JHpft4e,WWd,U9d

            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas