File tree Expand file tree Collapse file tree 4 files changed +30
-11
lines changed
src/test/java/io/github/jsonSnapshot Expand file tree Collapse file tree 4 files changed +30
-11
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.shouldMatchSnapshotFive =[" ));
51
+ "io.github.jsonSnapshot.SnapshotIntegrationTest.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 1
- io .github .jsonSnapshot .SnapshotIntegrationTest .shouldMatchSnapshotThree = [
1
+ io .github .jsonSnapshot .SnapshotIntegrationTest .shouldThrowSnapshotMatchException = [
2
2
{
3
- " id" : " anyId3 " ,
4
- " value" : 3 ,
5
- " name" : " anyName3 "
3
+ " id" : " anyId5 " ,
4
+ " value" : 5 ,
5
+ " name" : " anyName5 "
6
6
}
7
7
]
8
8
9
9
10
- io .github .jsonSnapshot .SnapshotIntegrationTest .shouldMatchSnapshotFive = [
10
+ io .github .jsonSnapshot .SnapshotIntegrationTest .shouldMatchSnapshotThree = [
11
11
{
12
- " id" : " anyId5 " ,
13
- " value" : 5 ,
14
- " name" : " anyName5 "
12
+ " id" : " anyId3 " ,
13
+ " value" : 3 ,
14
+ " name" : " anyName3 "
15
15
}
16
16
]
17
17
You can’t perform that action at this time.
0 commit comments