Maven项目中,命令执行特定的testng.xml配置文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>TheDemo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
      ...
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <!-- <suiteXmlFile>${testng.xml}</suiteXmlFile>配置,然后执行:mvn test -Dtestng.xml=xxx.xml(需要执行testng文件名) -->
                    <suiteXmlFiles>
                        <suiteXmlFile>${testng.xml}</suiteXmlFile>
                    </suiteXmlFiles>
                    <reportsDirectory>${basedir}/test-out</reportsDirectory>

                </configuration>
            </plugin>
            <plugin>
              
            </plugin>
        </plugins>
    </build>

</project>
原文地址:https://www.cnblogs.com/zizhuxuexi/p/14772947.html