Added tests for the Race class

- Added a test to ensure all boats entered into the race also finish it
- #test
This commit is contained in:
Michael Rausch
2017-03-04 19:30:00 +13:00
parent 5492ace1a3
commit 1b345d4747
2 changed files with 20 additions and 1 deletions
+1
View File
@@ -9,6 +9,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class BoatTest public class BoatTest
{ {
@Test @Test
public void testBoatCreation() public void testBoatCreation()
{ {
+19 -1
View File
@@ -10,8 +10,11 @@ import java.lang.reflect.Array;
*/ */
public class RaceTest public class RaceTest
{ {
/*
Test that all boats that were added to the race also finish the race
*/
@Test @Test
public void testAddingBoatsToRace() public void testFinishingBoats()
{ {
Boat boat1 = new Boat("Team 1"); Boat boat1 = new Boat("Team 1");
Boat boat2 = new Boat("Team 2"); Boat boat2 = new Boat("Team 2");
@@ -24,4 +27,19 @@ public class RaceTest
assertEquals(Array.getLength(race.getFinishedBoats()), 3); assertEquals(Array.getLength(race.getFinishedBoats()), 3);
} }
/*
Test that all boats were added to the race
*/
@Test
public void testAddingBoatsToRace(){
Boat boat1 = new Boat("Team 1");
Boat boat2 = new Boat("Team 2");
Race race = new Race();
race.addBoat(boat1);
race.addBoat(boat2);
assertEquals(Array.getLength(boats.getBoats()), 2);
}
} }