Skip to content

Commit 2956c7b

Browse files
feat: added test for name change
1 parent 4ab87a7 commit 2956c7b

File tree

1 file changed

+18
-4
lines changed
  • lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/xaviercruz

1 file changed

+18
-4
lines changed

lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/xaviercruz/PersonTest.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.codedifferently.lesson16.xaviercruz;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertThrows;
5-
63
import java.util.ArrayList;
74
import java.util.Arrays;
85

6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertThrows;
98
import org.junit.jupiter.api.Test;
109

1110
public class PersonTest {
@@ -16,6 +15,12 @@ public void testGetName(){
1615
assertEquals("That one guy right there", person.getName());
1716
}
1817

18+
@Test
19+
public void testChangeName(){
20+
person.changeName("new name right here bruh");
21+
assertEquals("new name right here bruh", person.getName());
22+
}
23+
1924
@Test
2025
public void testGetAge(){
2126
assertEquals(25, person.getAge());
@@ -49,12 +54,21 @@ public void testUpdateAge(){
4954
}
5055

5156
@Test
52-
public void testAddToTraits_Exception() throws TooManyTraitsException{
57+
public void testAddToTraits_Exception(){
5358
String[] newTraits = new String[]{"test", "test", "test", "test", "test", "test", "test"};
5459
assertThrows(TooManyTraitsException.class, () -> {
5560
person.addToTraits(newTraits);
5661
});
5762
}
5863

64+
@Test
65+
public void testSetEyeColor() {
66+
Color color = Color.GREEN;
67+
68+
person.setEyeColor(color);
69+
70+
assertEquals(Color.GREEN, person.getEyeColor());
71+
}
72+
5973

6074
}

0 commit comments

Comments
 (0)