通过Maven通过命令行运行特定的Testng套件



我试图使用命令行在Maven中运行特定的测试套件。

我有两个不同的套房
smoke.xml regression.xml

我的pom.xml文件看起来像

<groupId>com.FNB</groupId>
<artifactId>FNB_Testing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FNB_Testing</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>      
</properties>
<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.11</version>
        <scope>test</scope>
    </dependency>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>/FNB_Testing/regression.xml</suiteXmlFile>
                    <suiteXmlFile>/FNB_Testing/smoke.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

我正在使用命令mvn test -DsuiteXmlFile=*suite name*

但是,即使使用somke.xml,它也只会运行回归套件

您可以参数化多个套件文件,如

<suiteXmlFiles>
 <!-- Pass testng.xml files as argument from command line -->
    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>

然后使用maven执行以下命令来参数化多个testng.xml文件:

mvn clean test -Dsurefire.suiteXmlFiles=regression.xml,smoke.xml

最新更新