java - 执行目标 maven-failsafe-plugin : (failsafe-integration-tests) project x: suiteXmlFiles is configured, 但没有 TestNG 依赖

标签 java maven

我正在使用 Maven 故障安全插件与 cobertura 插件一起执行集成测试用例。 在故障安全插件的配置中,我给出了 suiteXmlFile ,它包含所有集成测试 但是,当运行以下命令时,我收到错误 命令是: mvn cobertura:cobertura-integration -DskipITs=false 错误是:

无法在项目 xx 上执行目标 maven-failsafe-plugin:2.17:integration-test (failsafe-integration-tests):配置了 suiteXmlFiles,但没有 TestNG 依赖项

这是 pom.xml 的片段

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.17</version>
  <configuration>
    <suiteXmlFiles>
      <suiteXmlFile>/home/adam/coberturaint/reporting/src/test/resources/testng/it-test.xml</suiteXmlFile>
    </suiteXmlFiles>
    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>6.8.8</version>
        </dependency>
      </dependencies>
    </dependencyManagement>

  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.8.8</version>
    </dependency>
  </dependencies>

</plugin>

我正在使用故障安全插件版本:2.17

我已经在各处提到了 testng 的依赖性,但我仍然收到依赖性错误 请建议

问候

最佳答案

您需要采取不同的方式,因为消息已经出现了。

<?xml version='1.0' encoding='UTF-8'?>
<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.8</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>


  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.17</version>
          <configuration>
            <suiteXmlFiles>
              <suiteXmlFile>/home/adam/coberturaint/reporting/src/test/resources/testng/it-test.xml</suiteXmlFile>
            </suiteXmlFiles>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

</project>

除此之外,您还需要像这样调用 Maven:

mvn verify

运行集成测试阶段。如果你像这样调用 Maven:

mvn cobertura:cobertura-integration 

您没有不运行集成测试的生命周期。

您应该避免在 pom 文件中使用绝对路径,就像处理套件文件一样。另一方面,问题是为什么您需要套件文件。在 TestNG 中通常你不需要它。

关于java - 执行目标 maven-failsafe-plugin : (failsafe-integration-tests) project x: suiteXmlFiles is configured, 但没有 TestNG 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26233462/

相关文章:

java - JVM 到底什么时候抛出 OutOfMemoryError

Tomcat Web 应用程序中的 java TCP 服务器

android - 将 Maven 存储库添加到 build.gradle

java - 使用 WinRun4j 记录 Windows 服务中的异常

java - 使用Windows任务计划程序自动执行WAR文件

Java:如何从不同的模块读取文件?

java - Maven编译错误: (use -source 7 or higher to enable diamond operator)

java - 从另一个 Maven 项目调用测试类

java - 如何让EntityManager执行原生sql

java - 通过 Logback 记录到 App Engine request_log