diff --git a/test/GameTest.java b/test/GameTest.java index b721aa7..6de9bc4 100644 --- a/test/GameTest.java +++ b/test/GameTest.java @@ -1,9 +1,36 @@ import static org.junit.jupiter.api.Assertions.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + + class GameTest { - @org.junit.jupiter.api.Test - void checkTest() { + private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + private final ByteArrayOutputStream errContent = new ByteArrayOutputStream(); + private final PrintStream originalOut = System.out; + private final PrintStream originalErr = System.err; + + @Before + public void setUpStreams() { + System.setOut(new PrintStream(outContent)); + System.setErr(new PrintStream(errContent)); + } + @After + public void restoreStreams() { + System.setOut(originalOut); + System.setErr(originalErr); + } + + @Test + void checkTest() { + System.out.println("hello"); + assertEquals("hello", outContent.toString()); } } \ No newline at end of file