【问题标题】:如何在一组中运行 maven 中指定的 testng.xml 文件?
【发布时间】:2022-01-22 06:28:17
【问题描述】:

我正在为一个项目创建一个批次的多个测试套件。我有一个回归测试和一个冒烟测试。我需要从批处理文件中调用它,所以我需要在发布后运行回归,但每天都吸烟。但是当我运行时

cd %projectLocation%
call mvn clean test -DsuiteXmlFile=smokeTestRunner.xml 

在文件中它仍然首先跳转到回归测试。这是我的万无一失的插件配置:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <suiteXmlFiles>
                        <!-- TestNG suite XML files -->
                        <suiteXmlFile>regressionTestRunner.xml</suiteXmlFile>
                        <suiteXmlFile>smokeTestRunner.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>

如何让它分别只运行冒烟测试或回归测试? runner.xml 文件和 pom.xml 都在同一个目录中

【问题讨论】:

  • N. B.: cd %projectLocation% 应该是 cd /D "%projectLocation%"...

标签: batch-file testng testng.xml


【解决方案1】:

在 pom 中试试这个:

 <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>{suite}.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

然后在终端运行:

mvn clean test -Dsuite=smokeTestRunner

mvn clean test -Dsuite=regressionTestRunner

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-29
    • 2017-08-08
    • 1970-01-01
    • 2012-05-18
    • 1970-01-01
    • 2017-10-09
    • 1970-01-01
    • 2020-03-08
    相关资源
    最近更新 更多