需要并行运行TestNG套件和测试

问题描述 投票:1回答:1

我有3个测试NG文件。 Machine1.xml:

<suite name="Machine1" verbose="1" parallel="tests" thread-count="1">
<test name="LoginTest">
<classes>
<class name="test.app.home.LoginTest"/>
</classes>
</test>
</suite>

Machine2.xml

<suite name="Machine2" verbose="1" parallel="tests" thread-count="1">
<test name="LoginTest">
<classes>
<class name="test.app.home.LoginTest"/>
</classes>
</test>
</suite>

MachineMain.xml

<suite name="testng" verbose="1" parallel="tests" thread-count="2">
<tests>
<test name="Machine1">
<suite-files> 
<suite-file path="Machine1.xml"/> 
</suite-files>
</test>
<test name="Machine2">
<suite-files> 
<suite-file path="Machine2.xml"/> 
</suite-files>
</test>
</tests>
</suite>

注意:我正在通过eclipse运行MachineMain.xml。我编写了代码来打开setupWebDriver里面的setup方法,我在安装方法上面有@BeforeSuite注释。

我正在尝试:我有一个集线器和2个节点,两个节点都有maxInstance为1.我试图通过在每个节点中打开一个浏览器并行运行2 xml - Machine1.xml和Machine2.xml(套件) - 基本上是一个节点(机器1)中的Machine1.xml套件和另一个节点(机器2)中的Machine2.xml套件。

发生了什么:集线器向一个节点(机器1)发送第一个Machine1.xml请求,在完成执行后,第二个机器2.xml被挑选并发送到第二个节点(机器2)。

我期待因为我在'test'标签内指定'suite-file'并在MachineMain.xml中将'parallel'值指定为'tests'并将'thread-count'值指定为2,它会自动并行执行套件。

请帮我解决这个问题。

testng selenium-grid
1个回答
0
投票

根据您的要求,您不需要两个xml。按照以下步骤操作,您应该并行运行相同的测试。

我假设你已经完成了网格设置,你知道所需的能力。如果没有,请参阅此链接https://code.google.com/p/selenium/wiki/Grid2

  1. 在一个testng xml中创建两个测试,并为每个测试提供一个浏览器版本参数。保持parallel = tests,套件标记中的线程数= 2。
  2. 在setup方法中使用capability对象中的版本,使其与节点配置匹配。
© www.soinside.com 2019 - 2024. All rights reserved.