Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
500 views
in Technique[技术] by (71.8m points)

testng - 需要并行运行TestNG套件和测试(Need to run TestNG suites and tests in parallel)

I have 3 test NG files.

(我有3个测试NG文件。)

Machine1.xml:

(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

(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

(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>

Note: I am running the MachineMain.xml through eclipse.

(注意:我正在通过Eclipse运行MachineMain.xml。)

I have written the code to open the remoteWebDriver inside setup method and i have @BeforeSuite annotation just above the setup method.

(我已经编写了在设置方法内部打开remoteWebDriver的代码,并且在设置方法上方有@BeforeSuite批注。)

What i am trying: I have a hub and 2 nodes, both the nodes have maxInstance as 1. I am trying to run the 2 xml - Machine1.xml and Machine2.xml (Suites) in parallel by opening one browser in each node - Basically Machine1.xml suite in one node (Machine 1) and Machine2.xml suite in the other node (Machine 2).

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

What is happeing: The hub sends first Machine1.xml request to one Node (Machine 1) and after it finishes the execution, the second Machine2.xml is picked and sent to second Node (Machine 2).

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

I was expecting that since i have specifed 'suite-file' inside 'test' tag and specified "parallel" value to 'tests' and "thread-count" value to 2 in MachineMain.xml, it would automatically execute the suites in parallel.

(我期待着,因为我已经在'test'标记中指定了'suite-file',并且在MachineMain.xml中将“ parallel”值指定为'tests'并且将“ thread-count”值指定为2,所以它将自动并行执行套件。)

Please help me resolve the issue.

(请帮助我解决问题。)

  ask by user2356679 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You dont need two xml for your requirement.

(您不需要两个xml来满足您的需求。)

Follow these steps and you should have same test running parallel.

(请按照下列步骤,您应该并行运行相同的测试。)

I am assuming that since you have grid setup done, you aware of desiredcapabilities.

(我假设既然已经完成了网格设置,那么您就会知道所需的功能。)

If not refer this link https://code.google.com/p/selenium/wiki/Grid2

(如果没有,请参考此链接https://code.google.com/p/selenium/wiki/Grid2)

  1. Create two tests in one testng xml and have a parameter for browser version for each test.

    (在一个testng xml中创建两个测试,并为每个测试使用一个浏览器版本参数。)

    Keep parallel = tests, thread count = 2 in suite tag.

    (保持并行=测试,套件标签中的线程数= 2。)

  2. Use the version in capabilities object in your setup method so that it matches the node configuration.

    (在设置方法中使用功能对象中的版本,以使其与节点配置匹配。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...