Fussball/test/TestPlayer.java
2024-06-10 00:35:29 +02:00

44 lines
1.7 KiB
Java

import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertThrows;
public class TestPlayer {
@Test
public void createFieldPlayerTest() {
//Instanz von Player erstellen, damit ich createFieldPlayer überhaupt aufrufen kann.
Player player = new Player();
//Instanz von Fieldplayer erstellen
FieldPlayer fieldPlayer = player.createFieldPlayer("Westermann", Position.DEFENDER, 1,2,3,1);
//Die Attribute von FieldPlayer werden alle einzeln geprüft!
assertEquals("Westermann", fieldPlayer.getName());
assertEquals(Position.DEFENDER, fieldPlayer.getPosition());
assertEquals(1, fieldPlayer.getKondition());
assertEquals(2, fieldPlayer.getZweikampf());
assertEquals(3, fieldPlayer.getKopfball());
assertEquals(1, fieldPlayer.getTechnik());
}
@Test
public void createGoalkeeperTest() {
//Klassenobjekt um create aufrufen zu können
Player player = new Player();
//Testobjekt, das gegen getestet wird.
Goalkeeper goalkeeper = player.createGoalkeeper("Lehmann", Position.GOALKEEPER, 5, 5);
//Jedes Attribut einzeln testen
assertEquals("Lehmann", goalkeeper.getName());
assertEquals(Position.GOALKEEPER, goalkeeper.getPosition());
assertEquals(5, goalkeeper.getReflexe());
assertEquals(5, goalkeeper.getStrafraum());
}
//Testet die Position exception, die im Konstruktor von Goalkeeper ist.
@Test(expectedExceptions = IllegalArgumentException.class)
public void goalkeeperExceptionTest(){
Player player =new Player();
Goalkeeper goalkeeper = player.createGoalkeeper("Hanslik",Position.STRIKER,1,1);
}
}