File tree 3 files changed +92
-0
lines changed
junit5/src/main/java/com/baeldung/junit5
3 files changed +92
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .baeldung .junit5 ;
2
+
3
+ import static org .junit .Assert .assertEquals ;
4
+
5
+ import org .junit .AfterClass ;
6
+ import org .junit .FixMethodOrder ;
7
+ import org .junit .Test ;
8
+ import org .junit .runners .MethodSorters ;
9
+
10
+ @ FixMethodOrder (MethodSorters .DEFAULT )
11
+ public class DefaultOrderOfExecutionTest {
12
+ private static StringBuilder output = new StringBuilder ("" );
13
+
14
+ @ Test
15
+ public void secondTest () {
16
+ output .append ("b" );
17
+ }
18
+
19
+ @ Test
20
+ public void thirdTest () {
21
+ output .append ("c" );
22
+ }
23
+
24
+ @ Test
25
+ public void firstTest () {
26
+ output .append ("a" );
27
+ }
28
+
29
+ @ AfterClass
30
+ public static void assertOutput () {
31
+ assertEquals (output .toString (), "cab" );
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .junit5 ;
2
+
3
+ import org .junit .FixMethodOrder ;
4
+ import org .junit .Test ;
5
+ import org .junit .runners .MethodSorters ;
6
+
7
+ @ FixMethodOrder (MethodSorters .JVM )
8
+ public class JVMOrderOfExecutionTest {
9
+
10
+ private static StringBuilder output = new StringBuilder ("" );
11
+
12
+ @ Test
13
+ public void secondTest () {
14
+ output .append ("b" );
15
+ }
16
+
17
+ @ Test
18
+ public void thirdTest () {
19
+ output .append ("c" );
20
+ }
21
+
22
+ @ Test
23
+ public void firstTest () {
24
+ output .append ("a" );
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .junit5 ;
2
+
3
+ import static org .junit .Assert .assertEquals ;
4
+
5
+ import org .junit .AfterClass ;
6
+ import org .junit .FixMethodOrder ;
7
+ import org .junit .Test ;
8
+ import org .junit .runners .MethodSorters ;
9
+
10
+ @ FixMethodOrder (MethodSorters .NAME_ASCENDING )
11
+ public class NameAscendingOrderOfExecutionTest {
12
+ private static StringBuilder output = new StringBuilder ("" );
13
+
14
+ @ Test
15
+ public void secondTest () {
16
+ output .append ("b" );
17
+ }
18
+
19
+ @ Test
20
+ public void thirdTest () {
21
+ output .append ("c" );
22
+ }
23
+
24
+ @ Test
25
+ public void firstTest () {
26
+ output .append ("a" );
27
+ }
28
+
29
+ @ AfterClass
30
+ public static void assertOutput () {
31
+ assertEquals (output .toString (), "abc" );
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments