有4个类测试TestClass1, TestClasss2, TestClass3, TestClass4
。您需要创建2个测试套件,每个套件将包含2个类,并使用Maven surefire plugin
并行运行。
我创建了2个包含以下内容的xml文件:
<suite name="TestSuite" verbose="1">
<test name="Test">
<classes>
<class name="Tests.TestClass1">
</class>
<class name="Tests.TestClass2">
</class>
</classes>
</test>
</suite>
和
<suite name="TestSuite1" verbose="1">
<test name="Test1">
<classes>
<class name="Tests.TestClass3">
</class>
<class name="Tests.TestClass4">
</class>
</classes>
</test>
</suite>
还添加到pom.xml
inmaven-surefire-plugin
以下内容:
<configuration>
<suiteXmlFiles>
<suiteXmlFile>Testng.xml</suiteXmlFile>
<suiteXmlFile>Testng1.xml</suiteXmlFile>
</suiteXmlFiles>
<parallel>suite</parallel>
<perCoreThreadCount>false</perCoreThreadCount>
<threadCount>2</threadCount>
</configuration>
接下来,我使用命令mvn clean test
运行项目,项目将进行,但测试无法启动。我哪里错了?
UPD:
该项目正在建设中,但测试尚未开始
文件testng.xml位于根文件夹中
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.469 sec - in T
estSuite
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.288 s
[INFO] Finished at: 2018-08-27T15:52:21+03:00
[INFO] ------------------------------------------------------------------------
请尝试以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<suiteXmlFiles>
<file>src/test/resources/testng.xml</file>
<file>src/test/resources/testng1.xml</file>
</suiteXmlFiles>
<properties>
<property>
<name>suitethreadpoolsize</name>
<value>2</value>
</property>
<property>
<name>surefire.testng.verbose</name>
<value>10</value>
</property>
</properties>
</configuration>
</plugin>