gruppe06-hufflepuff-projekt.../test/GameTest.java

78 lines
1.8 KiB
Java
Raw Normal View History

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
2021-10-08 09:51:14 +02:00
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Klasse GameTest
*
* Diese Klasse beinhaltet und führt alle Testfälle für die Klasse GameTest aus
*
*/
2021-10-08 09:15:24 +02:00
class GameTest {
private final PrintStream standardOut = System.out;
private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
private Game game = new Game();
@BeforeEach
public void beforeEach() {
game = new Game();
System.setOut(new PrintStream(outputStreamCaptor));
2021-10-08 09:51:14 +02:00
}
@AfterEach
public void tearDown() {
System.setOut(standardOut);
2021-10-08 09:51:14 +02:00
}
2021-10-08 09:15:24 +02:00
// Konstruktive Testfälle
/**
*
*/
2021-10-08 09:51:14 +02:00
@Test
public void placeOneField() {
game.placeField(1);
2021-10-08 09:15:24 +02:00
}
@Test
public void testGameShouldbeTie() {
game.placeField(1);
game.placeField(2);
game.placeField(3);
game.placeField(5);
game.placeField(4);
game.placeField(6);
game.placeField(8);
game.placeField(7);
game.placeField(9);
}
// Destruktive Testfälle
@Test
public void placeNotExistingField() {
System.out.println("Hello Baeldung Readers!!");
System.out.println("Hello Baeldung Readers!!");
System.out.println("Hello Baeldung Readers!!");
System.out.println("Hello Baeldung Readers!!");
assertEquals("Hello Baeldung Readers!!\n" +
"Hello Baeldung Readers!!\n" +
"Hello Baeldung Readers!!\n" +
"Hello Baeldung Readers!!", outputStreamCaptor.toString()
.trim());
}
2021-10-08 09:15:24 +02:00
}