使用Maven surefire运行全部或特定TestNg.xml测试

时间:2020-07-10 20:16:34

标签: maven testng maven-surefire-plugin

我想根据maven参数运行testng.xml单个测试或所有测试。 这是我的pom片段

logback.xml

Testng.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${suiteXml}</suiteXmlFile>
                    </suiteXmlFiles>
                    <properties>
                        <property>
                        <name>testnames</name>
                        <value>${testname}</value>
                        </property>
                    </properties>
                </configuration>
            </plugin>
        </plugins>
    </build>

我想使用上面的代码段实现低于两次的运行

//应该运行所有test-1。...test-n,但是必须提供失败的bcs testname,并且如果我提供testname,则所有测试都不会运行。

MVN测试-DsuiteXml = src / test / resources / testng.xml

//应该仅运行通过测试名(Test-1),按预期方式运行

MVN测试-DsuiteXml = src / test / resources / testng.xml -Dtestname = Test-1

0 个答案:

没有答案
相关问题