Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run maven tests in a specific order? [duplicate]

I have a maven project and several test classes.

I want to run these tests in a specific order with the plug-in surefire.

For example, I have:

  • ClassTest1.java
  • ClassTest2.java
  • ClassTest3.java
  • ClassTest4.java

I want to run the Class 1, then 2, then 3 and finally 4.

How can I specify this in the pom.xml?

like image 405
Kazman Avatar asked Dec 25 '22 07:12

Kazman


1 Answers

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.

like image 191
Marlon Bernardes Avatar answered Dec 28 '22 05:12

Marlon Bernardes