I have a JUnit 5 test consisting of multiple steps executing in order. The steps are defined in separate methods.
I want the tests to stop executing at first failure in the fixture/class.
This is behaviour which can be achieved in Spock by using @Stepwise annotation. I don't see how this can be done in JUnit 5.
Edit: added sample test
@TestMethodOrder(Alphanumeric.class)
class MainTest {
@Test void test1() {
assertTrue(true);
System.out.printf("%d test 1 - ok%n", System.currentTimeMillis());
}
@Test void test2() {
assertTrue(false);
System.out.printf("%d test 2 -nok%n", System.currentTimeMillis());
}
@Test void test3() {
assertTrue(true);
System.out.printf("%d test 3 - ok%n", System.currentTimeMillis());
}
@Test void test4() {
assertTrue(true);
System.out.printf("%d test 4 - ok%n", System.currentTimeMillis());
}
}
Gives the following result:
1596054675044 test 1 - ok
1596054675075 test 2
org.opentest4j.AssertionFailedError:
Expected :true
Actual :false
1596054675111 test 3 - ok
1596054675115 test 4 - ok