You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
830 B
35 lines
830 B
package Application;
|
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.PrintStream;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
class CliTest {
|
|
|
|
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
|
private final PrintStream originalOut = System.out;
|
|
|
|
Cli cli;
|
|
|
|
@BeforeEach
|
|
void setUp() {
|
|
System.setOut(new PrintStream(outContent));
|
|
cli = new Cli(System.out);
|
|
}
|
|
|
|
@AfterEach
|
|
void tearDown() {
|
|
System.setOut(originalOut);
|
|
}
|
|
|
|
@Test
|
|
void getPrintStream() {
|
|
cli.getPrintStream().println("Hello World!");
|
|
assertEquals("Hello World!\n", outContent.toString().replaceAll("\r", ""));
|
|
}
|
|
}
|