【发布时间】: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关于运行逻辑