-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathGettingStartedTest.java
More file actions
106 lines (97 loc) · 2.73 KB
/
GettingStartedTest.java
File metadata and controls
106 lines (97 loc) · 2.73 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package org.approvaltests;
import org.approvaltests.awt.AwtApprovals;
import org.approvaltests.combinations.CombinationApprovals;
import org.approvaltests.machine_specific_tests.TvGuide;
import org.approvaltests.namer.NamedEnvironment;
import org.approvaltests.namer.NamerFactory;
import org.junit.jupiter.api.Test;
import java.awt.*;
public class GettingStartedTest
{
@Test
void testBasicCall()
{
String objectToBeVerified = "Now is the time for all good coders to come to the aid of their countrypersons";
// begin-snippet: basic_verified_call
Approvals.verify(objectToBeVerified);
// end-snippet
}
// begin-snippet: verifying_strings
@Test
public void testBuildString()
{
/* Do */
// create a string with "Approval" and append "Tests" to it
String s = "Approval";
s += " Tests";
/* Verify */
// Verify the resulting string
Approvals.verify(s);
}
// end-snippet
// begin-snippet: verifying_objects
@Test
public void testObject()
{
/* Do */
// create an 100 x 200 rectangle with the top corner at (5, 10)
Rectangle objectUnderTest = new Rectangle(5, 10, 100, 200);
/* Verify */
// Verify the rectangle is properly defined
Approvals.verify(objectUnderTest.toString());
}
// end-snippet
@Test
public void testObjectWithJson()
{
/* Do */
// create an 100 x 200 rectangle with the top corner at (5, 10)
Rectangle objectUnderTest = new Rectangle(5, 10, 100, 200);
/* Verify */
// Verify the rectangle is properly defined
// begin-snippet: verifying_objects_with_json
JsonApprovals.verifyAsJson(objectUnderTest);
// end-snippet
}
// begin-snippet: verifying_arrays
@Test
public void testArray()
{
/* Do */
// create a String Array and set values in the indexes
String[] s = new String[2];
s[0] = "Approval";
s[1] = "Tests";
/* Verify */
// Verify the array
Approvals.verifyAll("Text", s);
}
// end-snippet
@Test
public void testTvGuide()
{
try (NamedEnvironment namedEnvironment = NamerFactory.asOsSpecificTest())
{
if (!namedEnvironment.isCurrentEnvironmentValidFor(false, "Windows_10"))
{ return; }
}
// begin-snippet: verifying_gui
/* Do */
// create a TV Guide and select a show for 3pm
TvGuide tv = new TvGuide();
tv.selectTime("3pm");
/* Verify */
// Verify the TvGuide
AwtApprovals.verify(tv);
// end-snippet
}
@Test
public void testCombinations()
{
// begin-snippet: verify_combinations
Integer[] lengths = new Integer[]{4, 5, 10};
String[] words = new String[]{"Bookkeeper", "applesauce"};
CombinationApprovals.verifyAllCombinations((i, s) -> s.substring(0, i), lengths, words);
// end-snippet
}
}