Search in sources :

Example 1 with ISuite

use of org.testng.ISuite in project druid by druid-io.

the class RemoteTestNG method buildTestRunnerFactory.

/**
   * Override by the plugin if you need to configure differently the <code>TestRunner</code>
   * (usually this is needed if different listeners/reporters are needed).
   * <b>Note</b>: you don't need to worry about the wiring listener, because it is added
   * automatically.
   */
protected ITestRunnerFactory buildTestRunnerFactory() {
    //################### PATCH STARTS
    if (System.getProperty("testrunfactory") != null) {
        m_customTestRunnerFactory = (ITestRunnerFactory) ClassHelper.newInstance(ClassHelper.fileToClass(System.getProperty("testrunfactory")));
    //################## PATCH ENDS
    } else if (null == m_customTestRunnerFactory) {
        m_customTestRunnerFactory = new ITestRunnerFactory() {

            @Override
            public TestRunner newTestRunner(ISuite suite, XmlTest xmlTest, List<IInvokedMethodListener> listeners) {
                TestRunner runner = new TestRunner(getConfiguration(), suite, xmlTest, false, /*skipFailedInvocationCounts */
                listeners);
                if (m_useDefaultListeners) {
                    runner.addListener(new TestHTMLReporter());
                    runner.addListener(new JUnitXMLReporter());
                }
                return runner;
            }
        };
    }
    return m_customTestRunnerFactory;
}
Also used : TestHTMLReporter(org.testng.reporters.TestHTMLReporter) JUnitXMLReporter(org.testng.reporters.JUnitXMLReporter) ISuite(org.testng.ISuite) TestRunner(org.testng.TestRunner) ITestRunnerFactory(org.testng.ITestRunnerFactory) XmlTest(org.testng.xml.XmlTest) List(java.util.List)

Example 2 with ISuite

use of org.testng.ISuite in project arrow by NetEase.

the class PowerEmailableReporter method generateMethodDetailReport.

/** 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());
        }
    }
}
Also used : ISuite(org.testng.ISuite) ITestContext(org.testng.ITestContext) ISuiteResult(org.testng.ISuiteResult)

Example 3 with ISuite

use of org.testng.ISuite in project arrow by NetEase.

the class PowerEmailableReporter method generateMethodSummaryReport.

/**
	 * 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>");
}
Also used : ISuite(org.testng.ISuite) ITestContext(org.testng.ITestContext) ISuiteResult(org.testng.ISuiteResult)

Example 4 with ISuite

use of org.testng.ISuite in project arrow by NetEase.

the class PowerEmailableReporter method generateSuiteSummaryReport.

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>");
}
Also used : ISuite(org.testng.ISuite) ITestContext(org.testng.ITestContext) DecimalFormat(java.text.DecimalFormat) ISuiteResult(org.testng.ISuiteResult) NumberFormat(java.text.NumberFormat)

Aggregations

ISuite (org.testng.ISuite)4 ISuiteResult (org.testng.ISuiteResult)3 ITestContext (org.testng.ITestContext)3 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 List (java.util.List)1 ITestRunnerFactory (org.testng.ITestRunnerFactory)1 TestRunner (org.testng.TestRunner)1 JUnitXMLReporter (org.testng.reporters.JUnitXMLReporter)1 TestHTMLReporter (org.testng.reporters.TestHTMLReporter)1 XmlTest (org.testng.xml.XmlTest)1