-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsuranceProgramTest.java
More file actions
60 lines (46 loc) · 1.53 KB
/
InsuranceProgramTest.java
File metadata and controls
60 lines (46 loc) · 1.53 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
package ie.atu.sw;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class InsuranceProgramTest {
public static InsuranceProgram testProg;
// Although we are requested to include the following annotations, the tests
// included in this suite did not require three of them.
// Java garbage collection should clean up any created data structures
// automatically, and better than I could.
@BeforeAll
static void setUpBeforeClass() throws Exception {
testProg = new InsuranceProgram();
}
@AfterAll
static void tearDownAfterClass() throws Exception {
}
@BeforeEach
void setUp() throws Exception {
}
@AfterEach
void tearDown() throws Exception {
}
// Test that the getScanner method returns a nun-null result
@Test
void getScannerTest() {
assertNotNull(InsuranceProgram.getScanner());
}
// Test that the getAge method throws the correct exception when no scanner is passed to it
@Test
void getAgeNoScannerExceptionTest() {
assertThrows(NullPointerException.class, () -> {
InsuranceProgram.getAge(null);
});
}
// Test that the getAccident method throws the correct exception when no scanner is passed to it
@Test
void getAccidentsNoScannerExceptionTest() {
assertThrows(NullPointerException.class, () -> {
InsuranceProgram.getAccidents(null);
});
}
}