Beispiel #1
0
 @Test
 public void testNotOkTestResult() {
   assertNotNull(notOkTestResult);
   assertTrue(notOkTestResult.getTestNumber() > 0);
   assertEquals(notOkTestResult.getStatus(), StatusValues.NOT_OK);
   assertNull(notOkTestResult.getDirective());
 }
Beispiel #2
0
 @Test
 public void testOkTestResultSkip() {
   assertNotNull(okTestResultSkip);
   assertTrue(okTestResultSkip.getTestNumber() > 0);
   okTestResultSkip.setStatus(StatusValues.OK);
   assertEquals(okTestResultSkip.getStatus(), StatusValues.OK);
   assertNotNull(okTestResultSkip.getDirective());
 }
  @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 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 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);
  }