是否可以仅针对我的 Maven POM 文件中列出的两个 TestNG xml 文件之一?
我的 Maven POM 文件指向两个 xml 文件:uat.xml 和 preprod.xml,我如何使用 mvn clean compile test 等 maven 命令仅针对其中一个 xml 文件?
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<!--<executable>C:\Program Files\Java\jdk1.8.0_121\bin\javac.exe</executable> -->
<executable>${env.JAVA_HOME}\bin\javac.exe</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>uat.xml</suiteXmlFile>
<suiteXmlFile>preprod.xml</suiteXmlFile>
</suiteXmlFiles>
<testErrorIgnore>false</testErrorIgnore>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
最佳答案
见下文。您将按名称引用该文件。所以,
mvn clean test -Dtestfile=uat.xml
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testfile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
关于java - 可以通过 Maven POM 文件定位特定的 TestNG.xml 文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47557917/