1
1
package io .github .jsonSnapshot ;
2
2
3
3
import org .apache .commons .lang3 .StringUtils ;
4
- import org .junit .AfterClass ;
5
- import org .junit .BeforeClass ;
6
- import org .junit .FixMethodOrder ;
7
- import org .junit .Test ;
8
- import org .junit .runner .RunWith ;
9
- import org .junit .runners .MethodSorters ;
10
- import org .mockito .runners .MockitoJUnitRunner ;
4
+ import org .junit .jupiter .api .AfterAll ;
5
+ import org .junit .jupiter .api .BeforeAll ;
6
+ import org .junit .jupiter .api .Test ;
7
+ import org .junit .jupiter .api .extension .ExtendWith ;
8
+ import org .mockito .junit .jupiter .MockitoExtension ;
11
9
12
10
import java .io .File ;
13
11
import java .io .IOException ;
16
14
17
15
import static org .assertj .core .api .Assertions .assertThat ;
18
16
19
- @ RunWith (MockitoJUnitRunner .class )
20
- @ FixMethodOrder (MethodSorters .NAME_ASCENDING )
17
+ @ ExtendWith (MockitoExtension .class )
21
18
public class SnapshotMatcherTest {
22
19
23
20
private static final String FILE_PATH = "src/test/java/io/github/jsonSnapshot/SnapshotMatcherTest.snap" ;
24
21
25
- @ BeforeClass
22
+ @ BeforeAll
26
23
public static void beforeAll () {
27
24
SnapshotMatcher .start ();
28
25
}
29
26
30
- @ AfterClass
27
+ @ AfterAll
31
28
public static void afterAll () throws IOException {
32
29
SnapshotMatcher .validateSnapshots ();
30
+ File f = new File (FILE_PATH );
31
+ assertThat (StringUtils .join (Files .readAllLines (f .toPath ()), "\n " )).
32
+ isEqualTo ("io.github.jsonSnapshot.SnapshotMatcherTest.should1ShowSnapshotSuccessfully=[\n " +
33
+ " \" any type of object\" \n " +
34
+ "]\n \n \n " +
35
+ "io.github.jsonSnapshot.SnapshotMatcherTest.should2SecondSnapshotExecutionSuccessfully=[\n " +
36
+ " \" any second type of object\" ,\n " +
37
+ " \" any third type of object\" \n " +
38
+ "]" );
33
39
Files .delete (Paths .get (FILE_PATH ));
34
40
}
35
41
@@ -41,16 +47,7 @@ public void should1ShowSnapshotSuccessfully() throws IOException {
41
47
if (!f .exists () || f .isDirectory ()) {
42
48
throw new RuntimeException ("File should exist here" );
43
49
}
44
-
45
- assertThat (StringUtils .join (Files .readAllLines (f .toPath ()), "\n " )).isEqualTo ("" );
46
-
47
50
SnapshotMatcher .expect ("any type of object" ).toMatchSnapshot ();
48
-
49
- assertThat (StringUtils .join (Files .readAllLines (f .toPath ()), "\n " )).
50
- isEqualTo ("io.github.jsonSnapshot.SnapshotMatcherTest.should1ShowSnapshotSuccessfully=[\n " +
51
- " \" any type of object\" \n " +
52
- "]" );
53
-
54
51
}
55
52
56
53
@ Test
@@ -60,17 +57,6 @@ public void should2SecondSnapshotExecutionSuccessfully() throws IOException {
60
57
if (!f .exists () || f .isDirectory ()) {
61
58
throw new RuntimeException ("File should exist here" );
62
59
}
63
-
64
60
SnapshotMatcher .expect ("any second type of object" , "any third type of object" ).toMatchSnapshot ();
65
-
66
- assertThat (StringUtils .join (Files .readAllLines (f .toPath ()), "\n " )).
67
- isEqualTo ("io.github.jsonSnapshot.SnapshotMatcherTest.should1ShowSnapshotSuccessfully=[\n " +
68
- " \" any type of object\" \n " +
69
- "]\n \n \n " +
70
- "io.github.jsonSnapshot.SnapshotMatcherTest.should2SecondSnapshotExecutionSuccessfully=[\n " +
71
- " \" any second type of object\" ,\n " +
72
- " \" any third type of object\" \n " +
73
- "]" );
74
-
75
61
}
76
62
}
0 commit comments