In general, this solution will be useful to anyone who wants to test consistently and in a given order.
It creates a suite, where in the annotation we list the classes in the order of execution:
@RunWith (Suite.class)
@ Suite.SuiteClasses ({OpenConnection.class,
GetServerIdTest.class,
ModbusStatusCodesTest.class,
ModbusSerialTransactionTest.class,
CloseConnection.class})
public class OrderedTestSuite {}
Add the plugin to pom.xml:
<plugin>
<groupId> org.apache.maven.plugins </groupId>
<artifactId> maven-surefire-plugin </artifactId>
<configuration>
<includes>
<include> ** / OrderedTestSuite.class </include>
</includes>
</configuration>
</plugin>