简体   繁体   English

基于TestNG的Selenium测试不能并行运行

[英]TestNG Based Selenium Tests not running in Parallel

I am using the below TestNG Config to enable parallel execution of Selenium tests. 我使用下面的TestNG Config来启用Selenium测试的并行执行。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Test-Automation" parallel="methods" thread-count="2" verbose="1">

    <test name="Suite Test">
        <classes>
            <class name="SampleTest">
                <methods>
                    <include name="firstTest"/>
                    <include name="secondTest"/>
                    <include name="thirdTest"/>
                </methods>
            </class>
        </classes>
    </test>
</suite>

Java Code: Java代码:

@Test(dataProvider = "TestData")
public void firstTest(String data){
   //Code
}

@Test(dataProvider = "TestData")
public void secondTest(String data){
   //Code
}

@Test(dataProvider = "TestData")
public void thirdTest(String data){
   //Code
}

The Selenium tests are expected to run in parallel. 预计Selenium测试将并行运行。 I expect 2 browsers to be open and run the test script. 我希望打开2个浏览器并运行测试脚本。

But I see only 1 browser and all 3 tests run one after the other and not in parallel. 但我看到只有一个浏览器,所有3个测试一个接一个地运行而不是并行运行。 I have tried using test, methods, class, instance options for "parallel" attribute. 我已经尝试使用“并行”属性的测试,方法,类,实例选项。

Any help? 有帮助吗?

This is due to a bug in TestNG 6.13.1 [ See GITHUB-1636 for more details ] 这是由于TestNG 6.13.1中的一个错误[更多细节请参见GITHUB-1636 ]

I have fixed this in the latest SNAPSHOT of TestNG (6.14-SNAPSHOT) and this should be available for use in the released version of TestNG (6.14). 我已经在最新的TestNG SNAPSHOT(6.14-SNAPSHOT)中解决了这个问题,这应该可以在TestNG的发布版本(6.14)中使用。

But until then, please alter your suite xml file to look like below : 但在此之前,请将您的套件xml文件更改为如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Test-Automation" parallel="methods" thread-count="2" verbose="1">
    <test name="Suite Test" parallel="methods" thread-count="2" verbose="1">
        <classes>
            <class name="SampleTest">
                <methods>
                    <include name="firstTest"/>
                    <include name="secondTest"/>
                    <include name="thirdTest"/>
                </methods>
            </class>
        </classes>
    </test>
</suite>

The work-around is basically to add the attributes parallel="methods" thread-count="2" at the <test> level also. 解决方法基本上是在<test>级别添加parallel="methods" thread-count="2"属性。

Seperate all the test and then try with parallel="test" 分开所有测试,然后尝试并行=“测试”

    <test name="Suite Test1">
        <classes>
              <class name="//..//packg name..SampleTest">

            </class>
        </classes>
    </test>
  <test name="Suite Test2">
        <classes>
            <class name="//..//SampleTest">

            </class>
        </classes>
    </test>
  <test name="Suite Test3">
        <classes>
            <class name="//..//packg name..SampleTest">

            </class>
        </classes>
    </test>

</suite>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium:TestNG:测试未并行运行 - Selenium: TestNG: Tests are not running in parallel 使用Selenium WebDriver,Selenium Grid和testNG运行并行测试 - Running Parallel Tests using Selenium WebDriver, Selenium Grid and testNG Selenium - TestNG:测试未并行运行 - 使用 selenium + java + browserstack - Selenium - TestNG: Tests are not running in parallel - Using selenium + java + browserstack 使用 TestNG、Appium 和 Selenium 运行并行和顺序测试 - Running parallel and sequential tests using TestNG, Appium and Selenium 在 testNG Selenium 中并行执行测试 - Parallel execution of tests in testNG Selenium 参数化硒测试与TestNG并行 - Parameterized Selenium Tests in Parallel with TestNG 如何通过使用 TestNG 和 Selenium 的方法并行运行测试 - How to run tests in parallel by methods with TestNG and Selenium 多个浏览器同时与Google Guice + TestNG + Selenium GRID + Maven并行运行测试 - Multiple browsers while running tests in parallel with Google Guice + TestNG + Selenium GRID + Maven 在使用 Spring 使用 testNG(Selenium) 运行测试时无法维持两个并行会话? - Unable to maintain two parallel sessions while running tests using testNG(Selenium) using Spring? 与 Selenium Grid 并行运行 TestNG 套件 - Running TestNG suite in parallel with Selenium Grid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM