import org.junit.jupiter.api.Test; import static org.mockito.Mockito.*; class ExecutorTest { @Test void printHelloWoldOnStdOut() { HelloWorldWriter outMock = mock(OutWriter.class); HelloWorldWriter errMock = mock(ErrorWriter.class); Executor.printHelloWorld(outMock, errMock, false); verify(outMock, times(1)).writeHelloWorld(); verify(errMock, times(0)).writeHelloWorld(); } @Test void printHelloWoldOnStdErr() { HelloWorldWriter outMock = mock(OutWriter.class); HelloWorldWriter errMock = mock(ErrorWriter.class); Executor.printHelloWorld(outMock, errMock, true); verify(outMock, times(0)).writeHelloWorld(); verify(errMock, times(1)).writeHelloWorld(); } }