-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathCatTest.java
More file actions
55 lines (53 loc) · 1.43 KB
/
CatTest.java
File metadata and controls
55 lines (53 loc) · 1.43 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
package io.zipcoder.pets;
import org.junit.Assert;
import org.junit.Test;
public class CatTest {
@Test
public void constructorTest() {
//given
String givenName = "Banksy";
Integer givenId = 0;
//when
Cat cat = new Cat(givenName, givenId);
String retrievedName = cat.getName();
Integer retrievedID = cat.getId();
//then
Assert.assertEquals(givenName, retrievedName);
Assert.assertEquals(givenId, retrievedID);
}
@Test
public void testGetName() {
//given
String expectedName = "Ony";
//when
Cat cat = new Cat(expectedName, 2);
String actualName = cat.getName();
//then
Assert.assertEquals(expectedName, actualName);
}
@Test
public void testGetID() {
//given
Integer expectedId = 1;
//when
Cat cat = new Cat("Kyo", expectedId);
Integer actualId = cat.getId();
//then
Assert.assertEquals(expectedId, actualId);
}
@Test
public void testSpeak() {
//given
String expectedSpeak = "Meow!";
//when
Cat newCat = new Cat("Spooky", 1);
String actualSpeak = newCat.speak();
//then
Assert.assertEquals(expectedSpeak, actualSpeak);
}
@Test
public void testPetInheritance() {
Cat newCat = new Cat("Gojo", 2);
Assert.assertTrue(newCat instanceof Pet);
}
}