我正面临着与Maven无关的问题,我无法在互联网上找到答案。感谢任何人都可以帮助我。我的目标是测试作为参数发送的2个testng文件到POM:
mvn clean test -DsuiteXmlFiles=1.xml,2.xml
并且POM文件是:
<plugins>
<!-- Following plugin executes the testng tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<!-- Suite testng xml file to consider for test execution -->
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<!-- Compiler plugin configures the java version to be usedfor compiling
the code -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
但是,当我运行时,它只运行2.xml文件并运行两次!!!
尝试了很多选项,但不管第二个xml文件是什么,它完全忽略第一个并运行第二个两次。
有人可以帮忙吗?
感谢
答案 0 :(得分:0)
您的surefire插件应如下所示
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<suiteXmlFiles>${file}</suiteXmlFiles>
<skipTests>false</skipTests>
</configuration>
</plugin>
密切关注<suiteXmlFiles>${file}</suiteXmlFiles>
现在您可以通过
传递多个套件文件mvn clean test -Dfile=src/test/resources/suite-one-with-execution.xml, src/test/resources/suite-two-with-execution.xml
有关详细信息,请参阅我的博文here。
答案 1 :(得分:0)
终于明白问题所在,由于某些原因我还不知道为什么,xml文件中的套件名称应该彼此不一样!!