@Test public void commandsAreNotRunForInvalidTests() throws Exception { commandList.add(command1); when(parsedTestUnit.getError()).thenReturn(Optional.of("Invalid Command on line 3")); TestResult testResult = singleTestRunner.runTest(lineBuffer, lineWriter, parsedTestUnit); assertEquals(TestResult.INVALID, testResult.getStatus()); verify(commandRunner, never()).runCommand(command1, lineBuffer, lineWriter); }
@Test public void testExceptionedCommandYieldsExceptionedTest() throws Exception { commandList.add(command1); when(commandRunner.runCommand(command1, lineBuffer, lineWriter)).thenReturn(commandResult1); when(commandResult1.getStatus()).thenReturn(CommandResult.EXCEPTION); TestResult testResult = singleTestRunner.runTest(lineBuffer, lineWriter, parsedTestUnit); assertEquals(TestResult.EXCEPTION, testResult.getStatus()); }
@Test public void testSuccessThenFailureYieldsFailedTest() throws Exception { commandList.add(command1); commandList.add(command2); when(commandRunner.runCommand(command1, lineBuffer, lineWriter)).thenReturn(commandResult1); when(commandRunner.runCommand(command2, lineBuffer, lineWriter)).thenReturn(commandResult2); when(commandResult1.getStatus()).thenReturn(CommandResult.SUCCESS); when(commandResult2.getStatus()).thenReturn(CommandResult.FAILURE); TestResult testResult = singleTestRunner.runTest(lineBuffer, lineWriter, parsedTestUnit); assertEquals(TestResult.FAILURE, testResult.getStatus()); }
@Test public void testCommandsAreNotRunAfterException() throws Exception { commandList.add(command1); commandList.add(command2); when(commandRunner.runCommand(command1, lineBuffer, lineWriter)).thenReturn(commandResult1); when(commandResult1.getStatus()).thenReturn(CommandResult.EXCEPTION); when(commandResult2.getStatus()).thenReturn(CommandResult.SUCCESS); TestResult testResult = singleTestRunner.runTest(lineBuffer, lineWriter, parsedTestUnit); assertEquals(TestResult.EXCEPTION, testResult.getStatus()); verify(commandRunner, never()).runCommand(command2, lineBuffer, lineWriter); }