File tree Expand file tree Collapse file tree 4 files changed +32
-12
lines changed
src/test/java/io/github/jsonSnapshot Expand file tree Collapse file tree 4 files changed +32
-12
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ Based on [facebook's Jest framework](https://facebook.github.io/jest/docs/en/sna
18
18
19
19
20
20
21
- #### How to install using Maven
21
+ #### How to install using [ Maven] ( https://mvnrepository.com/artifact/io.github.json-snapshot/json-snapshot/0.0.1 )
22
+
23
+
22
24
23
25
Add to your pom.xml dependencies section:
24
26
Original file line number Diff line number Diff line change 1
1
package io .github .jsonSnapshot ;
2
2
3
3
import lombok .Builder ;
4
+ import lombok .Setter ;
4
5
5
6
@ Builder
6
7
public class FakeObject {
@@ -11,4 +12,7 @@ public class FakeObject {
11
12
12
13
private String name ;
13
14
15
+ @ Setter
16
+ private FakeObject fakeObject ;
17
+
14
18
}
Original file line number Diff line number Diff line change @@ -45,10 +45,23 @@ public void shouldMatchSnapshotFour() {
45
45
}
46
46
47
47
@ Test
48
- public void shouldMatchSnapshotFive () {
48
+ public void shouldThrowSnapshotMatchException () {
49
49
expectedException .expect (SnapshotMatchException .class );
50
50
expectedException .expectMessage (startsWith ("Error on: \n " +
51
- "io.github.jsonSnapshot.SnapshotIntegrationTest| with |shouldMatchSnapshotFive =[" ));
51
+ "io.github.jsonSnapshot.SnapshotIntegrationTest| with |shouldThrowSnapshotMatchException =[" ));
52
52
expect (FakeObject .builder ().id ("anyId5" ).value (6 ).name ("anyName5" ).build ()).toMatchSnapshot ();
53
53
}
54
+
55
+ @ Test
56
+ public void shouldThrowStackOverflowError () {
57
+ expectedException .expect (StackOverflowError .class );
58
+
59
+ // Create cycle JSON
60
+ FakeObject fakeObject1 = FakeObject .builder ().id ("anyId1" ).value (1 ).name ("anyName1" ).build ();
61
+ FakeObject fakeObject2 = FakeObject .builder ().id ("anyId2" ).value (2 ).name ("anyName2" ).build ();
62
+ fakeObject1 .setFakeObject (fakeObject2 );
63
+ fakeObject2 .setFakeObject (fakeObject1 );
64
+
65
+ expect (fakeObject1 ).toMatchSnapshot ();
66
+ }
54
67
}
Original file line number Diff line number Diff line change @@ -7,15 +7,6 @@ io.github.jsonSnapshot.SnapshotIntegrationTest| with |shouldMatchSnapshotThree=[
7
7
]
8
8
9
9
10
- io .github .jsonSnapshot .SnapshotIntegrationTest | with | shouldMatchSnapshotFive = [
11
- {
12
- " id" : " anyId5" ,
13
- " value" : 5 ,
14
- " name" : " anyName5"
15
- }
16
- ]
17
-
18
-
19
10
io .github .jsonSnapshot .SnapshotIntegrationTest | with | shouldMatchSnapshotFour = [
20
11
{
21
12
" id" : " anyId4" ,
@@ -40,4 +31,14 @@ io.github.jsonSnapshot.SnapshotIntegrationTest| with |shouldMatchSnapshotTwo=[
40
31
" value" : 2 ,
41
32
" name" : " anyName2"
42
33
}
34
+ ]
35
+
36
+
37
+
38
+ io .github .jsonSnapshot .SnapshotIntegrationTest | with | shouldThrowSnapshotMatchException = [
39
+ {
40
+ " id" : " anyId5" ,
41
+ " value" : 5 ,
42
+ " name" : " anyName5"
43
+ }
43
44
]
You can’t perform that action at this time.
0 commit comments