Running features cucumber in parallel in different browser using selenium testNG

人走茶凉 提交于 2019-12-11 18:17:32

问题


How can i run cucumber features using testNG and selenium or cucumber-JVM i'm new in this but after my researsh i think that cucumber jvm doesn't work in paralell for me i added also the surefire plugin

now i try to test with TESTNG my testNg.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="run test in parallel Suite" parallel="tests" verbose="1" configfailurepolicy="continue" thread-count="2">

  <listeners>

        <listener classname="com.driver.LocalWebDriverListener" />
    </listeners>
    <test name="Tests in FF">
        <parameter name="browserName" value="firefox" />
        <classes>
            <class name="com.runner.RunnerTestInFirefox" />
        </classes>
    </test>
    <test name="Tests in Chrome" >
        <parameter name="browserName" value="chrome" />    
 <classes>
            <class name="com.runner.RunnerTestInChrome"/>
        </classes>
    </test>
</suite> <!-- Suite -->

and i create 2 class runner one for chrome and the other for firefox:

package com.runner;

    import org.junit.runner.RunWith;

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

    @RunWith(Cucumber.class)
    @CucumberOptions(
             features = {"/features"},
             glue={"stepsdefinition"})
    public class RunnerTestInChrome extends AbstractTestNGCucumberTests {

    }

when i run my test the browser chrome is open and closed but i don't why it didn't take the url and the steps in the feature!


回答1:


Afaik Cucumber does not support parallel execution, You might need to use an additional plugin or need to use gherkin with qaf. qaf is built upon TestNG for functional test automation, providing browser management, resource management, data-driven capability, detailed reports with screenshot and command-log...

When using gherkin with qaf, your configuration file may look like:

<suite name="run test in parallel Suite" parallel="tests" verbose="1" configfailurepolicy="continue" thread-count="2">
      <test name="Tests in FF">
            <parameter name="driver.name" value="firefoxDriver" />           
            <classes>
                  <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
            </classes>
      </test>
      <test name="Tests in Chrome">
            <parameter name="driver.name" value="chromeDriver"/>                      
            <classes>
                  <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
            </classes>
      </test>
</suite>

NOTE: If you want to run scenarios in parallel set parallel="methods" and thread-count accordingly.

You can start by walk-through step by step tutorial



来源:https://stackoverflow.com/questions/49551598/running-features-cucumber-in-parallel-in-different-browser-using-selenium-testng

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!