forked from fmendozaro/junit-tests
-
Notifications
You must be signed in to change notification settings - Fork 622
Expand file tree
/
Copy pathStudentTest.java
More file actions
65 lines (50 loc) · 1.47 KB
/
StudentTest.java
File metadata and controls
65 lines (50 loc) · 1.47 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
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class StudentTest {
Student studentOne;
Student studentTwo;
Student studentThree;
@Before
public void setUp() throws Exception {
studentOne = new Student(1,"John");
studentOne.addGrade(90);
studentOne.addGrade(100);
studentTwo = new Student(2, "James");
studentTwo.addGrade(50);
studentTwo.addGrade(100);
studentThree = new Student(3, "Tiffany");
}
@Test
public void testConstructor() {
Student s1 = new Student(1,"name");
assertEquals("name", s1.getName());
assertEquals(1,s1.getId());
assertTrue(s1.getGrades().isEmpty());
}
@Test
public void testGetId(){
assertEquals(1,studentOne.getId());
assertEquals(2, studentTwo.getId());
}
@Test
public void testGetName(){
assertEquals("John", studentOne.getName());
assertEquals("James", studentTwo.getName());
}
@Test
public void testAddGrade(){
assertTrue(studentThree.getGrades().isEmpty());
studentThree.addGrade(98);
assertFalse(studentThree.getGrades().isEmpty());
}
@Test
public void testGetGrades(){
assertSame(90,studentOne.getGrades().get(0));
assertSame(100,studentTwo.getGrades().get(1));
}
@Test
public void testGetGradeAverage(){
assertEquals(75, studentTwo.getGradeAverage(),0);
}
}