我想用testng執行並行運行。 我正在嘗試4次並行運行測試。但它只運行一次。使用testng並行運行
的testng.xml
<suite name="My suite" parallel="methods" thread-count="4">
<test name="Default test" group-by-instances="true">
<classes>
<class name="org.com.DemoClass"/>
</classes>
</test> <!-- Default test -->
</suite> <!-- Default suite -->
Demo類。
public class DemoClass {
@Test
public void method1() throws InterruptedException {
long id = Thread.currentThread().getId();
System.out.println("Before test-method. Thread id is: " + id);
}
}
請提供您寶貴的建議。
添加線程數並不意味着您的測試方法將運行多次。這意味着它們有多個可用於執行的線程。在你的情況下,你只有一個方法在一次測試中只執行一次。對@Test註釋包括一個innvocationCount參數。閱讀文檔 - http://testng.org/doc/documentation-main.html#parallel-running – Grasshopper
您能否提供一個示例來說明如何執行多個測試用例的並行運行? –