【问题标题】:Running Testng.xml from POM.xml is not running tests in sequence从 POM.xml 运行 Testng.xml 没有按顺序运行测试
【发布时间】:2020-08-03 17:31:47
【问题描述】:

我正在使用 POM.xml 通过添加编译器和万能插件来运行 testng.xml 文件。它运行测试,但测试顺序与预期不符。 我在 testng.xml 中提到了 10 个类,当我通过 testng.xml 运行时,它按该顺序运行。但是当通过 POM.xml 运行时,顺序是这样的;首先它运行所有类中提到的所有 0 优先级测试,然后是 1 优先级测试,依此类推。它应该根据 testng.xml 中提到的类顺序运行测试。 任何快速帮助将不胜感激。

   <build>
   <plugins>
    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
    <version>3.5.1</version>
    <configuration>
        <source>${jdk.level}</source>
        <target>${jdk.level}</target>  
        
    </configuration>
  </plugin>

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

 </plugins>

 </build>

【问题讨论】:

  • surefire 只是您的 TestNG XML 的运行器,我们需要 XML 来了解其中的逻辑,如果您为每个测试添加优先级也会影响 TestNG 的逻辑,我会推荐阅读TestNG documentation关于运行逻辑

标签: java xml maven testng


【解决方案1】:

在 testng 依赖项下,需要更改范围标记才能从 test 编译,它解决了这个问题,因为它需要在添加插件后编译构建。 它解决了这个问题。

【讨论】:

    猜你喜欢
    • 2014-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    相关资源
    最近更新 更多