Java Code Examples for org.gradle.api.tasks.testing.TestResult#getResultType()

The following examples show how to use org.gradle.api.tasks.testing.TestResult#getResultType() . 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: GradleTestSuiteCollector.java    From gradle-metrics-plugin with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
Result getTestResult(TestResult testResult) {
    TestResult.ResultType testResultType = testResult.getResultType();
    List<Throwable> exceptions = testResult.getExceptions();
    Result result;
    switch (testResultType) {
        case SUCCESS:
            result = Result.success();
            break;
        case SKIPPED:
            result = Result.skipped();
            break;
        case FAILURE:
            //noinspection ConstantConditions
            result = Result.failure(exceptions);
            break;
        default:
            logger.warn("Test result carried unknown result type '{}'. Assuming success", testResultType);
            result = Result.success();
    }
    return result;
}
 
Example 2
Source File: TestEventLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestLogEvent getEvent(TestResult result) {
    switch (result.getResultType()) {
        case SUCCESS: return TestLogEvent.PASSED;
        case FAILURE: return TestLogEvent.FAILED;
        case SKIPPED: return TestLogEvent.SKIPPED;
        default: throw new AssertionError();
    }
}
 
Example 3
Source File: TestCountLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void afterSuite(TestDescriptor suite, TestResult result) {
    if (suite.getParent() == null) {
        if (failedTests > 0) {
            logger.error(TextUtil.getPlatformLineSeparator() + summary());
        }
        progressLogger.completed();

        if (result.getResultType() == TestResult.ResultType.FAILURE) {
            hadFailures = true;
        }
    }
}
 
Example 4
Source File: TestEventLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestLogEvent getEvent(TestResult result) {
    switch (result.getResultType()) {
        case SUCCESS: return TestLogEvent.PASSED;
        case FAILURE: return TestLogEvent.FAILED;
        case SKIPPED: return TestLogEvent.SKIPPED;
        default: throw new AssertionError();
    }
}
 
Example 5
Source File: TestCountLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void afterSuite(TestDescriptor suite, TestResult result) {
    if (suite.getParent() == null) {
        if (failedTests > 0) {
            logger.error(TextUtil.getPlatformLineSeparator() + summary());
        }
        progressLogger.completed();

        if (result.getResultType() == TestResult.ResultType.FAILURE) {
            hadFailures = true;
        }
    }
}
 
Example 6
Source File: ErrorReportingTestListener.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTest(TestDescriptor testDescriptor, TestResult result) {
   // Include test failure exception stacktrace(s) in test output log.
   if (result.getResultType() == TestResult.ResultType.FAILURE) {
      if (result.getExceptions().size() > 0) {
         String message = formatter.format(testDescriptor, result.getExceptions());
         handlerFor(testDescriptor).write(message);
      }
   }
}
 
Example 7
Source File: TestEventLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestLogEvent getEvent(TestResult result) {
    switch (result.getResultType()) {
        case SUCCESS: return TestLogEvent.PASSED;
        case FAILURE: return TestLogEvent.FAILED;
        case SKIPPED: return TestLogEvent.SKIPPED;
        default: throw new AssertionError();
    }
}
 
Example 8
Source File: TestCountLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void afterSuite(TestDescriptor suite, TestResult result) {
    if (suite.getParent() == null) {
        if (failedTests > 0) {
            logger.error(TextUtil.getPlatformLineSeparator() + summary());
        }
        progressLogger.completed();

        if (result.getResultType() == TestResult.ResultType.FAILURE) {
            hadFailures = true;
        }
    }
}
 
Example 9
Source File: TestEventLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TestLogEvent getEvent(TestResult result) {
    switch (result.getResultType()) {
        case SUCCESS: return TestLogEvent.PASSED;
        case FAILURE: return TestLogEvent.FAILED;
        case SKIPPED: return TestLogEvent.SKIPPED;
        default: throw new AssertionError();
    }
}
 
Example 10
Source File: TestCountLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void afterSuite(TestDescriptor suite, TestResult result) {
    if (suite.getParent() == null) {
        if (failedTests > 0) {
            logger.error(TextUtil.getPlatformLineSeparator() + summary());
        }
        progressLogger.completed();

        if (result.getResultType() == TestResult.ResultType.FAILURE) {
            hadFailures = true;
        }
    }
}
 
Example 11
Source File: TestLogger.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTest(TestDescriptor test, TestResult result) {
    if (result.getResultType() == TestResult.ResultType.FAILURE) {
        LOGGER.error("## FAILURE: " + test);
        for (String output : testOutputs.getOrDefault(test, List.of())) {
            System.out.println(output);
        }
        for (Throwable exception : result.getExceptions()) {
            exception.printStackTrace();
        }
    }
    testOutputs.remove(test);
}
 
Example 12
Source File: TestMethodResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestMethodResult completed(TestResult result) {
    resultType = result.getResultType();
    duration = result.getEndTime() - result.getStartTime();
    endTime = result.getEndTime();
    return this;
}
 
Example 13
Source File: TestMethodResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestMethodResult completed(TestResult result) {
    resultType = result.getResultType();
    duration = result.getEndTime() - result.getStartTime();
    endTime = result.getEndTime();
    return this;
}
 
Example 14
Source File: TestMethodResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestMethodResult completed(TestResult result) {
    resultType = result.getResultType();
    duration = result.getEndTime() - result.getStartTime();
    endTime = result.getEndTime();
    return this;
}
 
Example 15
Source File: TestMethodResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestMethodResult completed(TestResult result) {
    resultType = result.getResultType();
    duration = result.getEndTime() - result.getStartTime();
    endTime = result.getEndTime();
    return this;
}