[英]How to run tests in parallel by methods with TestNG and Selenium
[英]How to run TestNG tests in parallel JVM process (not threads)
是否可以在兩個不同的 java 進程(JVM)中使用 TestNG 框架運行測試? 默認情況下,TestNG 創建一個進程,所有並行測試都在其中的不同線程中運行。 而且我需要將所有 static 內容包裝在 ThreadLocal<> 中,以使其成為線程安全的。 但是,如果有一種方法可以在兩個不同的進程中運行測試,我可以保持一切原樣。 我不想擔心線程安全。
TestNG 無法在多個進程中運行測試。 但是,至少 maven(我也希望 gradle)有一個插件可以完成這項工作。
See, how maven surefire plugin solves this: https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html .
您可以使用此配置示例(將其添加到 pom.xml,build->plugins 部分):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<forkCount>2</forkCount>
<reuseForks>false</reuseForks>
<reportsDirectory>target/surefire-reports-${surefire.forkNumber}</reportsDirectory>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/Suite1.xml</suiteXmlFile>
<suiteXmlFile>src/test/resources/Suite2.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.