Java Code Examples for org.testng.Reporter#getOutput()

The following examples show how to use org.testng.Reporter#getOutput() . 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: ExtentIReporterSuiteClassListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 7 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    ExtentService.getInstance().setReportUsesManualConfiguration(true);
    ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE);

    for (ISuite suite : suites) {
        Map<String, ISuiteResult> result = suite.getResults();

        for (ISuiteResult r : result.values()) {
            ITestContext context = r.getTestContext();

            ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName());
            buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL);
            buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP);
            buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS);
        }
    }

    for (String s : Reporter.getOutput()) {
        ExtentService.getInstance().setTestRunnerOutput(s);
    }

    ExtentService.getInstance().flush();
}
 
Example 2
Source File: ExtentIReporterSuiteListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 6 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    ExtentService.getInstance().setReportUsesManualConfiguration(true);
    ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE);

    for (ISuite suite : suites) {
        Map<String, ISuiteResult> result = suite.getResults();

        for (ISuiteResult r : result.values()) {
            ITestContext context = r.getTestContext();

            ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName());
            buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL);
            buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP);
            buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS);
        }
    }

    for (String s : Reporter.getOutput()) {
        ExtentService.getInstance().setTestRunnerOutput(s);
    }

    ExtentService.getInstance().flush();
}
 
Example 3
Source File: PowerEmailableReporter.java    From WebAndAppUITesting with GNU General Public License v3.0 4 votes vote down vote up
private void generateForResult(ITestResult ans, ITestNGMethod method, int resultSetSize) {
	Object[] parameters = ans.getParameters();
	boolean hasParameters = parameters != null && parameters.length > 0;
	if (hasParameters) {
		tableStart("result", null);
		m_out.print("<tr class=\"param\">");
		for (int x = 1; x <= parameters.length; x++) {
			m_out.print("<th>Parameter #" + x + "</th>");
		}
		m_out.println("</tr>");
		m_out.print("<tr class=\"param stripe\">");
		for (Object p : parameters) {
			m_out.println("<td>" + Utils.escapeHtml(p.toString()) + "</td>");
		}
		m_out.println("</tr>");
	}
	List<String> msgs = Reporter.getOutput(ans);
	boolean hasReporterOutput = msgs.size() > 0;
	Throwable exception = ans.getThrowable();
	boolean hasThrowable = exception != null;
	if (hasReporterOutput || hasThrowable) {
		if (hasParameters) {
			m_out.print("<tr><td");
			if (parameters.length > 1) {
				m_out.print(" colspan=\"" + parameters.length + "\"");
			}
			m_out.println(">");
		} else {
			m_out.println("<div>");
		}
		if (hasReporterOutput) {
			if (hasThrowable) {
				m_out.println("<h3>Test Messages</h3>");
			}
			for (String line : msgs) {
				m_out.println(line + "<br/>");
			}
		}
		if (hasThrowable) {
			boolean wantsMinimalOutput = ans.getStatus() == ITestResult.SUCCESS;
			if (hasReporterOutput) {
				m_out.println("<h3>" + (wantsMinimalOutput ? "Expected Exception" : "Failure") + "</h3>");
			}
			generateExceptionReport(exception, method);
		}
		if (hasParameters) {
			m_out.println("</td></tr>");
		} else {
			m_out.println("</div>");
		}
	}
	if (hasParameters) {
		m_out.println("</table>");
	}
}