-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathEmployeeTest.java
More file actions
49 lines (40 loc) · 1.15 KB
/
EmployeeTest.java
File metadata and controls
49 lines (40 loc) · 1.15 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
package test.java;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
import employee_stuff.Employee;
class EmployeeTest {
@Test
void testEmployeeInt() {
Employee e = new Employee(15);
assertEquals(15, e.getNumber());
}
@Test
void testEmployeeIntString() {
Employee e = new Employee(15, "Henry Banana");
assertEquals(15, e.getNumber());
assertEquals("Henry Banana", e.getName());
}
@Test
void testEmployeeIntStringFloat() {
Employee e = new Employee(15, "Henry Banana", 20000f);
assertEquals(15, e.getNumber());
assertEquals("Henry Banana", e.getName());
assertEquals(20000f, e.getSalary(), 0.000001);
}
@Test
void testSalaryMinFailure() {
Employee e = new Employee(15, "Henry Banana");
assertThrows(IllegalArgumentException.class, () -> {
e.setSalary(6999);
});
assertNotEquals(9999, e.getSalary());
}
@Test
void testSalaryMinSuccess() {
Employee e = new Employee(15, "Henry Banana");
e.setSalary(10000);
assertEquals(10000, e.getSalary());
}
}