Skip to content

Commit 6cb6996

Browse files
feat: added more tests
1 parent dd68734 commit 6cb6996

File tree

1 file changed

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

1 file changed

+18
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,28 @@ public void testUpdateAge(){
6464
}
6565

6666
@Test
67-
public void testAddToTraits_Exception(){
67+
public void testAddToTraitsStringArray_Exception(){
6868
String[] newTraits = new String[]{"test", "test", "test", "test", "test", "test", "test"};
6969
assertThrows(TooManyTraitsException.class, () -> {
7070
person.addToTraits(newTraits);
7171
});
7272
}
7373

74+
@Test
75+
public void testAddToTraitsString_Exception(){
76+
Person person2 = new Person("That one guy right there", 25, Position.ARSONIST, new ArrayList<>(Arrays.asList("Tall", "Insane", "Funny", "something else here idk", "test", "test", "test","test","test","test")), Color.RED);
77+
assertThrows(TooManyTraitsException.class, () -> {
78+
person2.addToTraits("newTrait");
79+
});
80+
}
81+
82+
@Test
83+
public void testAddToTraitsList_Exception(){
84+
Person person2 = new Person("That one guy right there", 25, Position.ARSONIST, new ArrayList<>(Arrays.asList("Tall", "Insane", "Funny", "something else here idk", "test", "test", "test","test","test","test")), Color.RED);
85+
var traits = new ArrayList<String>(Arrays.asList("testTrait"));
86+
assertThrows(TooManyTraitsException.class, () -> {
87+
person2.addToTraits(traits);
88+
});
89+
}
90+
7491
}

0 commit comments

Comments
 (0)