-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathcatTest.java
More file actions
75 lines (64 loc) · 1.66 KB
/
catTest.java
File metadata and controls
75 lines (64 loc) · 1.66 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
66
67
68
69
70
71
72
73
74
75
package io.zipcoder.petsTest;
import io.zipcoder.pets.*;
import org.junit.Assert;
import org.junit.Test;
public class catTest {
@Test
public void catConstructorTest(){
//Given
String givenName = "Taco";
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 speakTest(){
//given
Cat cat = new Cat("Taco", 1);
String bark = "Meow";
//when
String retrievedSpeak = cat.speak();
//then
Assert.assertEquals(bark, retrievedSpeak);
}
@Test
public void getIdTest(){
//given
Integer givenId = 1;
Cat cat = new Cat("Taco", givenId);
//when
Integer retrievedId = cat.getId();
//then
Assert.assertEquals(givenId, retrievedId);
}
@Test
public void inheritanceOfPetTest(){
//given
Cat cat = new Cat("Taco", 1);
//then
Assert.assertTrue(cat instanceof Pet);
}
@Test
public void inheritanceOfAnimalTest(){
//given
Cat cat = new Cat("Taco", 1);
//then
Assert.assertTrue(cat instanceof Animal);
}
@Test
public void setNameTest() {
// Given
Cat cat = new Cat(null, null);
String givenName = "Chubby";
// When
cat.setName(givenName);
// Then
String catName = cat.getName();
Assert.assertEquals(catName, givenName);
}
}