+ Created UnitTest for class Game
This commit is contained in:
parent
5beb3d5dbb
commit
675e75818f
|
@ -1,9 +1,36 @@
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
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 {
|
class GameTest {
|
||||||
|
|
||||||
@org.junit.jupiter.api.Test
|
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
void checkTest() {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue