Java Code Examples for org.apache.maven.plugins.surefire.report.ReportTestSuite#getNumberOfFailures()

The following examples show how to use org.apache.maven.plugins.surefire.report.ReportTestSuite#getNumberOfFailures() . 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: AbstractRepairMojo.java    From repairnator with MIT License 6 votes vote down vote up
public List<String> getFailingTests() {
    List<String> result = new ArrayList<>();

    for (MavenProject mavenProject : reactorProjects) {
        File surefireReportsDirectory = getSurefireReportsDirectory(mavenProject);
        SurefireReportParser parser = new SurefireReportParser(Collections.singletonList(surefireReportsDirectory), Locale.ENGLISH, new NullConsoleLogger());

        try {
            List<ReportTestSuite> testSuites = parser.parseXMLReportFiles();
            for (ReportTestSuite reportTestSuite : testSuites) {
                if (reportTestSuite.getNumberOfErrors()+reportTestSuite.getNumberOfFailures() > 0) {
                    result.add(reportTestSuite.getFullClassName());
                }
            }
        } catch (MavenReportException e) {
            e.printStackTrace();;
        }

    }

    return result;
}
 
Example 2
Source File: UnitTestMojo.java    From wisdom with Apache License 2.0 5 votes vote down vote up
private static void computeTestFailureMessageFromReports(StringBuilder message, SurefireReportParser parser)
        throws MavenReportException {
    List<ReportTestSuite> suites = parser.parseXMLReportFiles();
    Map<String, String> summary = parser.getSummary(suites);
    message
            .append(summary.get("totalTests"))
            .append(" tests, ")
            .append(summary.get("totalErrors"))
            .append(" errors, ")
            .append(summary.get("totalFailures"))
            .append(" failures, ")
            .append(summary.get("totalSkipped"))
            .append(" skipped ")
            .append("(executed in ")
            .append(summary.get("totalElapsedTime"))
            .append("s)<br/><ul>");
    for (ReportTestSuite suite : suites) {
        if (suite.getNumberOfErrors() > 0 || suite.getNumberOfFailures() > 0) {
            for (ReportTestCase tc : suite.getTestCases()) {
                if (tc.getFailure() != null
                        && !"skipped".equalsIgnoreCase((String) tc.getFailure().get("message"))) {
                    message
                            .append("<li><em>")
                            .append(tc.getFullName())
                            .append("</em> failed: ")
                            .append(tc.getFailure().get("message"))
                            .append("</li>");
                }
            }
        }
    }
    message.append("</ul>");
}