-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSampleTests.java
More file actions
54 lines (48 loc) · 1.14 KB
/
Copy pathSampleTests.java
File metadata and controls
54 lines (48 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.samples;
import org.approvaltests.Approvals;
import org.approvaltests.JsonApprovals;
import org.approvaltests.core.Options;
import org.approvaltests.reporters.AutoApproveReporter;
import org.approvaltests.reporters.UseReporter;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class SampleTests
{
@Test
void testNormalJunit()
{
assertEquals(5, 5);
}
@Test
void testWithApprovalTests()
{
Approvals.verify("Hello World");
}
/**
* note: this requires GSON which is currently added in the pom.xml file.
* This is only required if you want to use the VerifyAsJson.
**/
@Test
void testJson()
{
Person hero = new Person("jayne", "cobb", true, 38);
JsonApprovals.verifyAsJson(hero);
}
/***
* This only works in java 15+
@Test
void testInline()
{
var expected = """
{
"firstName": "jayne",
"lastName": "cobb",
"isMale": true,
"age": 38
}
""";
Person hero = new Person("jayne", "cobb", true, 38);
JsonApprovals.verifyAsJson(hero, new Options().inline(expected));
}
***/
}