Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import junit.framework.TestCase;
- import java.io.ByteArrayOutputStream;
- import java.io.PrintStream;
- public class HelloWorldTest extends TestCase {
- public void testHelloWorld() {
- final var oldSystemOut = System.out;
- final var outputStream = new ByteArrayOutputStream();
- System.setOut(new PrintStream(outputStream));
- try {
- HelloWorld.main(null);
- } finally {
- System.setOut(oldSystemOut);
- }
- assertEquals("Hello world!" + System.lineSeparator(), outputStream.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement