Java Code Examples for org.testng.ISuite#getResults()

The following examples show how to use org.testng.ISuite#getResults() . 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 6 votes vote down vote up
/** Creates a section showing known results for each method */
protected void generateMethodDetailReport(List<ISuite> suites) {
	for (ISuite suite : suites) {
		Map<String, ISuiteResult> r = suite.getResults();
		for (ISuiteResult r2 : r.values()) {
			ITestContext testContext = r2.getTestContext();
			if (r.values().size() > 0) {
				m_out.println("<h1>" + testContext.getName() + "</h1>");
			}
			resultDetail(testContext.getFailedConfigurations());
			resultDetail(testContext.getFailedTests());
			resultDetail(testContext.getSkippedConfigurations());
			resultDetail(testContext.getSkippedTests());
			resultDetail(testContext.getPassedTests());
		}
	}
}
 
Example 4
Source File: CustomAutomationReport.java    From pxf with Apache License 2.0 5 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {

	StringBuilder sBuilder = new StringBuilder();

	// Iterating over each suite
	for (ISuite suite : suites) {

		// Getting the results for the each suite
		Map<String, ISuiteResult> suiteResults = suite.getResults();
		for (ISuiteResult sr : suiteResults.values()) {
			// get context for result
			ITestContext tc = sr.getTestContext();
			// go over all cases
			for (ITestNGMethod method : tc.getAllTestMethods()) {
				// if a case has "ExpectedFaiGPDBWritable.javalure" annotation, insert to sBuilder

				if (method.getConstructorOrMethod().getMethod().getAnnotation(ExpectedFailure.class) != null) {
					sBuilder.append(method.getInstance().getClass().getName() + "/" + method.getMethodName()).append(System.lineSeparator());
				}
			}
		}
	}

	// write results to file
	try {
		FileUtils.writeStringToFile(new File(outputDirectory + "/automation_expected_failures.txt"), sBuilder.toString(), false);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 5
Source File: PowerEmailableReporter.java    From WebAndAppUITesting with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a table showing the highlights of each test method with links to
 * the method details
 */
protected void generateMethodSummaryReport(List<ISuite> suites) {
	startResultSummaryTable("methodOverview");
	int testIndex = 1;
	for (ISuite suite : suites) {
		if (suites.size() > 1) {
			titleRow(suite.getName(), 5);
		}
		Map<String, ISuiteResult> r = suite.getResults();
		for (ISuiteResult r2 : r.values()) {
			ITestContext testContext = r2.getTestContext();
			String testName = testContext.getName();
			m_testIndex = testIndex;

			// resultSummary(suite, testContext.getSkippedConfigurations(),
			// testName, "skipped",
			// " (configuration methods)");
			resultSummary(suite, testContext.getSkippedTests(), testName, "skipped", "");
			// resultSummary(suite, testContext.getFailedConfigurations(),
			// testName, "failed",
			// " (configuration methods)");
			resultSummary(suite, testContext.getFailedTests(), testName, "failed", "");
			resultSummary(suite, testContext.getPassedTests(), testName, "passed", "");

			testIndex++;
		}
	}
	m_out.println("</table>");
}
 
Example 6
Source File: TestReport.java    From PatatiumWebUi with Apache License 2.0 5 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory)
{
	List<ITestResult> list = new ArrayList<ITestResult>();
	for (ISuite suite : suites) {
		Map<String, ISuiteResult> suiteResults = suite.getResults();
		for (ISuiteResult suiteResult : suiteResults.values()) {
			ITestContext testContext = suiteResult.getTestContext();
			IResultMap passedTests = testContext.getPassedTests();
			IResultMap failedTests = testContext.getFailedTests();
			IResultMap skippedTests = testContext.getSkippedTests();
			IResultMap failedConfig = testContext.getFailedConfigurations();
			list.addAll(this.listTestResult(passedTests));
			list.addAll(this.listTestResult(failedTests));
			list.addAll(this.listTestResult(skippedTests));
			//list.addAll(this.listTestResult(failedConfig));
		}
	}
	CopyReportResources reportReource=new CopyReportResources();

	try {
		reportReource.copyResources();
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
	this.sort(list);
	this.outputResult(list, outputDirectory+"/report.html");


}
 
Example 7
Source File: PowerEmailableReporter.java    From WebAndAppUITesting with GNU General Public License v3.0 4 votes vote down vote up
public void generateSuiteSummaryReport(List<ISuite> suites) {
	tableStart("testOverview", null);
	m_out.print("<tr>");
	tableColumnStart("Test");
	tableColumnStart("Methods<br/>Passed");
	tableColumnStart("Scenarios<br/>Passed");
	tableColumnStart("# skipped");
	tableColumnStart("# failed");
	tableColumnStart("Total<br/>Time");
	tableColumnStart("Included<br/>Groups");
	tableColumnStart("Excluded<br/>Groups");
	m_out.println("</tr>");
	NumberFormat formatter = new DecimalFormat("#,##0.0");
	int qty_tests = 0;
	int qty_pass_m = 0;
	int qty_pass_s = 0;
	int qty_skip = 0;
	int qty_fail = 0;
	long time_start = Long.MAX_VALUE;
	long time_end = Long.MIN_VALUE;
	m_testIndex = 1;
	for (ISuite suite : suites) {
		if (suites.size() > 1) {
			titleRow(suite.getName(), 8);
		}
		Map<String, ISuiteResult> tests = suite.getResults();
		for (ISuiteResult r : tests.values()) {
			qty_tests += 1;
			ITestContext overview = r.getTestContext();
			startSummaryRow(overview.getName());

			getAllTestIds(overview, suite);
			int q = getMethodSet(overview.getPassedTests(), suite).size();
			qty_pass_m += q;
			summaryCell(q, Integer.MAX_VALUE);
			q = overview.getPassedTests().size();
			qty_pass_s += q;
			summaryCell(q, Integer.MAX_VALUE);

			q = getMethodSet(overview.getSkippedTests(), suite).size();
			qty_skip += q;
			summaryCell(q, 0);

			q = getMethodSet(overview.getFailedTests(), suite).size();
			qty_fail += q;
			summaryCell(q, 0);

			time_start = Math.min(overview.getStartDate().getTime(), time_start);
			time_end = Math.max(overview.getEndDate().getTime(), time_end);
			summaryCell(
					formatter.format((overview.getEndDate().getTime() - overview.getStartDate().getTime()) / 1000.)
							+ " seconds",
					true);
			summaryCell(overview.getIncludedGroups());
			summaryCell(overview.getExcludedGroups());
			m_out.println("</tr>");
			m_testIndex++;
		}
	}
	if (qty_tests > 1) {
		m_out.println("<tr class=\"total\"><td>Total</td>");
		summaryCell(qty_pass_m, Integer.MAX_VALUE);
		summaryCell(qty_pass_s, Integer.MAX_VALUE);
		summaryCell(qty_skip, 0);
		summaryCell(qty_fail, 0);
		summaryCell(formatter.format((time_end - time_start) / 1000.) + " seconds", true);
		m_out.println("<td colspan=\"2\">&nbsp;</td></tr>");
	}
	m_out.println("</table>");
}
 
Example 8
Source File: ReportLog.java    From teamengine with Apache License 2.0 4 votes vote down vote up
/**
 * Creates report logs that consists of test statics by extracting information from 
 * the Test suite results. These Report logs are then printed in the TestNG HTML reports.
 * 
 * @param suite is the test suite from which you want to extract test results information.
 */
public void generateLogs(ISuite suite) {
    Reporter.clear(); // clear output from previous test runs
    Reporter.log("The result of the test is-\n\n");

    //Following code gets the suite name
    String suiteName = suite.getName();
    //Getting the results for the said suite
    Map<String, ISuiteResult> suiteResults = suite.getResults();
    String input = null;
    String result;
    String failReport = null;
    String failReportConformance2=",";
    int passedTest = 0;
    int failedTest = 0;
    int skippedTest = 0;
    int finalPassedTest=0;
    int finalSkippedTest=0;
    int finalFailedTest=0;
    int count = 0;
    String date = null;
    for (ISuiteResult sr : suiteResults.values()) {
        count++;
        ITestContext tc = sr.getTestContext();
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Calendar cal = Calendar.getInstance();
        if (count == 1) {
            date = dateFormat.format(cal.getTime());
            input = tc.getAttribute("Input").toString();
            failReport = tc.getAttribute("TestResultReport").toString();
            passedTest = tc.getPassedTests().getAllResults().size();
            skippedTest = tc.getSkippedTests().getAllResults().size();
            failedTest = tc.getFailedTests().getAllResults().size();

        } else {
            int no_of_failedTest = tc.getFailedTests().getAllResults().size();
            int no_of_skippedTest = tc.getSkippedTests().getAllResults().size();
            int no_of_passedTest = tc.getPassedTests().getAllResults().size();
            if(no_of_failedTest!=0 || no_of_passedTest !=0)
            {
                if (no_of_failedTest == 0 && no_of_passedTest !=0 ) {
                failReportConformance2 = failReportConformance2+", "+input + " conform to the clause A." + count + " of "+suiteName;
            } else {
                    failReportConformance2 = failReportConformance2+", "+input + " does not conform to the clause A." + count + " of "+suiteName;
                
            }
            finalPassedTest = finalPassedTest + no_of_passedTest;
            finalSkippedTest = finalSkippedTest + no_of_skippedTest;
            finalFailedTest = finalFailedTest + no_of_failedTest;
        }
        }

    }
    failedTest+=finalFailedTest;
    skippedTest+=finalSkippedTest;
    passedTest+=finalPassedTest;
    if(failedTest>0){
      result="Fail";
    }else{
      result="Pass";
    }
    Reporter.log("**RESULT: " + result);
    Reporter.log("**INPUT: " + input);
    Reporter.log("**TEST NAME AND VERSION    :" + suiteName);
    Reporter.log("**DATE AND TIME PERFORMED  :" + date);
    Reporter.log("Passed tests for suite '" + suiteName
            + "' is:" + passedTest);

    Reporter.log("Failed tests for suite '" + suiteName
            + "' is:"
            + failedTest);

    Reporter.log("Skipped tests for suite '" + suiteName
            + "' is:"
            + skippedTest);
    Reporter.log("\nREASON:\n\n");
    Reporter.log(failReport);
    Reporter.log(failReportConformance2);

}