[英]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.