TestNG 并行执行 [英] TestNG parallel execution
问题描述
我有 4 个 @Test 方法,并且希望每个方法都运行 3 次.我想在 12 个线程中同时执行这一切.
I have 4 @Test methods and want to run each of them 3 times. I want to execute this all simultaneously, in 12 threads.
我创建了一个这样的 testng.xml 文件
I created a testng.xml file like this
<suite name="Suite1" verbose="1" parallel="methods" thread-count="100">
<test name="Test1">
<classes>
<class name="Tests"/>
</classes>
</test>
<test name="Test2">
<classes>
<class name="Tests"/>
</classes>
</test>
<test name="Test3">
<classes>
<class name="Tests"/>
</classes>
</test>
</suite>
如果我设置 parallel="methods" TestNG 会在 4 个线程中为 Test1 执行 4 个测试方法,然后为 Test2 执行相同的操作,然后为 Test3 执行相同的操作.但我不想在运行 Test2 之前等待 Test1 完成.TestNG 能够运行 Test1、Test2 &Test3 同时执行(如果 parallel="tests"),但在这种情况下,它为每个测试依次执行 4 个测试方法.
If I set parallel="methods" TestNG executes 4 test methods in 4 threads for Test1, after that does the same for Test2, and then for Test3. But I do not want to wait for Test1 completion before running Test2. TestNG is able to run Test1, Test2 & Test3 simultaneously (if parallel="tests") but in this case it executes 4 test methods in sequence for each Test.
有没有办法告诉 TestNG 根本不要等待并在单独的线程中启动所有测试的所有方法?
Is there a way to tell TestNG to not wait at all and start all methods for all Tests in separate threads?
推荐答案
让套件运行并行测试,然后每个测试都可以运行并行方法.类似的东西:
Have the suite run parallel tests and then each test can run parallel methods. Something like:
<suite name="Suite1" verbose="1" parallel="tests" thread-count="10">
<test name="Test1" parallel="methods" thread-count="4">
<classes>
<class name="Tests"/>
</classes>
</test>
<test name="Test2" parallel="methods" thread-count="4">
<classes>
<class name="Tests"/>
</classes>
</test>
<test name="Test3" parallel="methods" thread-count="4">
<classes>
<class name="Tests"/>
</classes>
</test>
</suite>
这篇关于TestNG 并行执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!