我想使用 testng Surefire插件 = “noreferrer”> Maven的。我们的想法是使用组integrationTest标记一些测试并运行插件两次:目标test排除组integration-test和目标pom.xml仅包括组mvn integration-test

我找到了一些资料,用于为两者运行插件目标和工作,但第二次运行的组不起作用(没有执行测试)。

以下是我的mvn test

的构建元素中的插件配置
  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <excludedGroups>integrationTest</excludedGroups>
      <reportFormat>brief</reportFormat>
      <trimStackTrace>true</trimStackTrace>
      <useFile>false</useFile>
    </configuration>
    <executions>
      <execution>
        <id>integration-test</id>
        <phase>integration-test</phase>
        <goals>
          <goal>test</goal>
        </goals>
        <configuration>
          <groups>integrationTest</groups>
          <excludedGroups/>
          <reportsDirectory>${project.build.directory}/surefire-reports/integration</reportsDirectory>
        </configuration>
      </execution>
    </executions>
  </plugin>

有什么想法吗? <=>按预期运行所有单元测试(不包括组<=>),但第二次测试运行只写:

  

运行TestSuite
  测试运行:0,失败:0,错误:0,跳过:0,已过去时间:0.562秒

<=>的结果与预期一致,测试运行且组<=>被忽略。

有帮助吗?

解决方案

我明白了 - 激怒配置实现!

<excludedGroups/>不会覆盖<excludedGroups>integrationTest</excludedGroups>。您需要指定任何(未知)组,例如<excludedGroups>none</excludedGroups>

其他提示

Failsafe插件是执行此操作的最佳方式(发布此问题时可能无法使用)。它为构建生命周期添加了集成测试阶段。它允许您在测试之前和之后运行设置和拆卸活动,例如,这对于管理嵌入式容器非常有用。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top