-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMonster.java
More file actions
49 lines (40 loc) · 951 Bytes
/
TestMonster.java
File metadata and controls
49 lines (40 loc) · 951 Bytes
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
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class TestMonster {
static Monster test;
static Hero h;
@BeforeAll
static void setUpBeforeClass() throws Exception {
test = new Bowler();
h = new Warrior();
}
@Test
void testheal() {
int health = test.getHitPoints();
for (int i = 0; i < 10; i ++) {
test.heal();
}
assertTrue(health < test.getHitPoints());
}
@Test
void testDrop() {
for (int i = 0; i < 10; i ++) {
test.randomDrop(h);
}
assertTrue(h.getInventory()[0] > 0);
}
@Test
void testAddHP() {
int health = test.getHitPoints();
test.addHitPoints(25);
assertEquals(health + 25 , test.getHitPoints());
}
@Test
void testSubtractHP() {
int health = test.getHitPoints();
test.subtractHitPoints(50, h);
//can heal
assertTrue(health > test.getHitPoints());
}
}