コード例 #1
0
  @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);
  }
コード例 #2
0
  @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());
  }
コード例 #3
0
  @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());
  }
コード例 #4
0
  @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);
  }