Java Code Examples for org.junit.platform.engine.TestExecutionResult#getStatus()

The following examples show how to use org.junit.platform.engine.TestExecutionResult#getStatus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllureJunitPlatform.java    From allure-java with Apache License 2.0 6 votes vote down vote up
@Override
public void executionFinished(final TestIdentifier testIdentifier,
                              final TestExecutionResult testExecutionResult) {
    // skip root
    if (!testIdentifier.getParentId().isPresent()) {
        return;
    }
    final Status status = extractStatus(testExecutionResult);
    final StatusDetails statusDetails = testExecutionResult.getThrowable()
            .flatMap(ResultsUtils::getStatusDetails)
            .orElse(null);

    if (testIdentifier.isTest()) {
        stopTestCase(testIdentifier, status, statusDetails);
    } else if (testExecutionResult.getStatus() != TestExecutionResult.Status.SUCCESSFUL) {
        // report failed containers as fake test results
        startTestCase(testIdentifier);
        stopTestCase(testIdentifier, status, statusDetails);
    }
    stopTestContainer(testIdentifier);
}
 
Example 2
Source File: TestPlanExecutionReport.java    From junit5-extensions with MIT License 6 votes vote down vote up
public final Builder addResult(TestIdentifier identifier, TestExecutionResult result) {
  DisplayName displayName = getDisplayName(identifier);

  if (identifier.isTest()) {
    testsBuilder().add(displayName);
  }

  switch (result.getStatus()) {
    case SUCCESSFUL:
      successfulBuilder().add(displayName);
      return this;
    case FAILED:
      failuresBuilder().put(displayName, result.getThrowable().orElse(null));
      return this;
    default:
      throw new AssertionError("Unhandled case in enum: " + result.getStatus());
  }
}
 
Example 3
Source File: AllureJunitPlatform.java    From allure-java with Apache License 2.0 5 votes vote down vote up
private Status extractStatus(final TestExecutionResult testExecutionResult) {
    switch (testExecutionResult.getStatus()) {
        case FAILED:
            return testExecutionResult.getThrowable().isPresent()
                    ? getStatus(testExecutionResult.getThrowable().get())
                    : FAILED;
        case SUCCESSFUL:
            return PASSED;
        default:
            return SKIPPED;
    }
}
 
Example 4
Source File: FlatPrintingTestListener.java    From sbt-jupiter-interface with Apache License 2.0 5 votes vote down vote up
@Override
public void executionFinished(TestIdentifier identifier, TestExecutionResult result) {

    String duration = calculateDurationSuffix(identifier.getUniqueId());
    Throwable throwable = result.getThrowable().orElse(null);
    String fqn, message;

    switch (result.getStatus()) {
        case ABORTED:
            fqn = configuration.buildErrorName(identifier);
            message = configuration.buildErrorMessage(throwable);
            message = "Test assumption in test " + fqn + " failed: " + message + duration;
            logger.warn(message);
            break;
        case FAILED:
            fqn = configuration.buildErrorName(identifier);
            message = configuration.buildErrorMessage(throwable);
            message = "Test " + fqn + " failed: " + message + duration;
            logger.error(configuration.extractClassName(identifier), message, throwable);
            break;
        case SUCCESSFUL:
            fqn = configuration.formatIdentifier(testPlan, identifier);
            message = "Test " + fqn + " finished" + duration;
            logger.debug(message);
            break;
    }
}
 
Example 5
Source File: TreePrintingTestListener.java    From sbt-jupiter-interface with Apache License 2.0 5 votes vote down vote up
@Override
public void executionFinished(TestIdentifier identifier, TestExecutionResult result) {

    Throwable throwable = result.getThrowable().orElse(null);
    String fqn, message;

    switch (result.getStatus()) {
        case ABORTED:
            fqn = configuration.buildErrorName(identifier);
            message = configuration.buildErrorMessage(throwable);
            message = "Test assumption in test " + fqn + " failed: " + message;
            logger.warn(message);
            break;
        case FAILED:
            fqn = configuration.buildErrorName(identifier);
            message = configuration.buildErrorMessage(throwable);
            message = "Test " + fqn + " failed: " + message;
            logger.error(configuration.extractClassName(identifier), message, throwable);
            break;
        case SUCCESSFUL:
            fqn = identifier.getLegacyReportingName();
            message = "Test " + fqn + " finished";
            logger.debug(message);
            break;
    }

    maybeDecreaseIndent(identifier);
}
 
Example 6
Source File: JupiterExecutionListener.java    From junit5-docker with Apache License 2.0 4 votes vote down vote up
@Override
public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult testExecutionResult) {
    allTestsPassed = allTestsPassed && testExecutionResult.getStatus() == SUCCESSFUL;
}