【问题标题】:How to run maven tests sequentially如何按顺序运行 Maven 测试
【发布时间】:2015-04-15 11:39:02
【问题描述】:

我有不同的班级,每个班级都有一个或多个测试。

我想使用 testing.xml 按顺序对每个类运行 maven 测试

testing.xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Suite1" verbose="1">
    <test name="Regression1">
        <classes>
            <class name="test.settings.SettingsTest"/>
            <class name="test.weather.WeatherTest"/>
        </classes>
    </test>
</suite>

当我在命令下运行时,它会运行所有测试。但我想按顺序一一运行 testing.xml 中指定的测试。

mvn -Dtests=testing.xml test

【问题讨论】:

  • 为什么像这样运行测试很重要。仅使用默认值的根本问题是什么?
  • @AshleyFrieze 我想按顺序运行测试。如果我使用 mvn 全新安装。所有测试都以并行顺序运行。
  • @vikingsteve 我想以任何随机顺序运行测试。但是一次运行一个测试。我不希望测试并行运行。
  • 好的,您尝试过 Adrian 的回答吗?
  • 也许有一些选项可以配置maven-surefire-plugin

标签: java maven testng sequential


【解决方案1】:

我不确定你的意思,但你试过了吗:

<test name="Regression1" parallel="false" preserve-order="true">

【讨论】:

    【解决方案2】:

    我错过了maven-surefire-plugin中的配置

    这是我尝试过的

    <plugins>
        [...]
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
              <suiteXmlFiles>
                <suiteXmlFile>testing.xml</suiteXmlFile>
              </suiteXmlFiles>
            </configuration>
          </plugin>
        [...]
    </plugins>
    

    在 testing.xml 中

    <test name="Regression1" parallel="false" preserve-order="true">
    

    现在可以使用了。

    【讨论】:

      猜你喜欢
      • 2014-08-06
      • 1970-01-01
      • 2015-12-21
      • 2015-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多