Last active
December 17, 2015 00:39
-
-
Save ecmendenhall/5523091 to your computer and use it in GitHub Desktop.
Testing printed terminal output with JUnit 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(JUnit4.class) | |
public class TerminalViewTest extends TicTacToeTest { | |
private final PrintStream stdout = System.out; | |
private final ByteArrayOutputStream output = new ByteArrayOutputStream(); | |
private TerminalView terminalview; | |
@Before | |
public void setUp() throws UnsupportedEncodingException { | |
terminalview = new TerminalView(); | |
System.setOut(new PrintStream(output, true, "UTF-8")); | |
} | |
@Test | |
public void terminalViewShouldPrintBoards() { | |
terminalview.print(nowins); | |
assertEquals(nowins.toString(), output.toString()); | |
} | |
@After | |
public void cleanUp() { | |
System.setOut(stdout); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment