After applying all the settings based on previous recommended solution. I'm still having the same reverse or random @order execution.
Pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
Maven Dependency Tree:
mvn dependency:tree -Dverbose -Dincludes=org.junit.jupiter:junit-jupiter-engine
[INFO] com.personalitytest.demo:personalitytest:jar:1.0-SNAPSHOT
[INFO] \- org.junit.jupiter:junit-jupiter-engine:jar:5.4.0:test
JUnit Test:
@SpringBootTest
@ActiveProfiles("test")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class JUnitOrderTest {
private static final Logger log = LoggerFactory.getLogger(JUnitOrderTest.class);
@Test
@Order(1)
public void testUploadSuccess() {
log.info("Junit - Order 1");
}
@Test
@Order(2)
public void testDownloadSuccess() {
log.info("Junit - Order 2");
}
@Test
@Order(3)
public void testDeleteSuccess() {
log.info("Junit - Order 3");
}
}
Output:
Running com.personalitytest.demo.security.JUnitOrderTest
08:48:35.470 [main] INFO com.personalitytest.demo.security.JUnitOrderTest - Junit - Order 2
08:48:35.480 [main] INFO com.personalitytest.demo.security.JUnitOrderTest - Junit - Order 3
08:48:35.481 [main] INFO com.personalitytest.demo.security.JUnitOrderTest - Junit - Order 1
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
https://junit.org/junit5/docs/current/api/org/junit/jupiter/api/TestMethodOrder.html – TweezersOrderAnnotation
class properly. @RuthiRuth the methods are manipulating files on a remote server, obviously, there the download/delete method will fail if I don't upload the file on the server first (I'd also like to keep the method separate - i.e. not calling the upload method in the download test). – Sabu@Test
annotation? – Bowl@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
– Mallette