如何按特定顺序运行maven测试? [英] How to run maven tests in a specific order?
本文介绍了如何按特定顺序运行maven测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个maven项目和几个测试类。
I have a maven project and several test classes.
我希望使用插件surefire以特定顺序运行这些测试。
I want to run these tests in a specific order with the plug-in surefire.
例如,我有:
- ClassTest1.java
- ClassTest2.java
- ClassTest3.java
- ClassTest4.java
- ClassTest1.java
- ClassTest2.java
- ClassTest3.java
- ClassTest4.java
我想运行Class 1,然后是2,然后是3,最后是4.
I want to run the Class 1, then 2, then 3 and finally 4.
我如何在pom.xml的?
How can I specify this in the pom.xml?
推荐答案
一种解决方法是将 runOrder
参数设置为按字母顺序排列,然后将测试重命名为按字母顺序排列。
One workaround is to set the runOrder
parameter to alphabetical and then rename your tests to have alphabetical order.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<runOrder>alphabetical</runOrder>
</configuration>
</plugin>
不推荐这样做 - 单元测试应该相互独立。执行顺序无关紧要。
This isn't recommended, though - unit tests should be independent of each other. The execution order shouldn't matter.
这篇关于如何按特定顺序运行maven测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文