-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestStudentSetAge.java
More file actions
58 lines (51 loc) · 1.25 KB
/
Copy pathTestStudentSetAge.java
File metadata and controls
58 lines (51 loc) · 1.25 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
import org.junit.Test;
import org.junit.experimental.categories.Category;
import static org.junit.Assert.*;
public class TestStudentSetAge {
@Test
public void testRigh() {
int[] marks= {10, 6, 9, 8};
Student s= new Student("Gigel", 20,
marks, EFaculty.CSIE);
try {
s.setAge(21);
assertEquals("compare age", 21, s.getAge());
} catch (ExceptionInputAge e) {
e.printStackTrace();
fail("for age under limits, the setter thrown an exception");
}
}
@Test
public void testBoundaryLowestValue() {
//testing for the age of 18
int[] marks= {10, 6, 9, 8};
Student s= new Student("Gigel", 20,
marks, EFaculty.CSIE);
try {
s.setAge(18);
assertEquals("compare age", 18, s.getAge());
} catch (ExceptionInputAge e) {
e.printStackTrace();
fail("for age under limits, the setter thrown an exception");
}
}
@Category(SlowTest.class)
@Test
public void testInverseRelationship2() {
int[] marks= {10, 6, 9, 8};
Student s= new Student("Gigel", 20,
marks, EFaculty.CSIE);
try {
s.setAge(25);
int actualValue=25;
for(int i=18; i<65; i++) {
if(i==actualValue)
i++;
assertNotEquals("test inverse", i, s.getAge());
}
} catch (ExceptionInputAge e) {
e.printStackTrace();
fail();
}
}
}