Search in sources :

Example 6 with ITestContext

use of org.testng.ITestContext 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 7 with ITestContext

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

the class PowerXMLReport method getSuiteAttributes.

private Properties getSuiteAttributes(ISuite suite) {
    Properties props = new Properties();
    props.setProperty(XMLReporterConfig.ATTR_NAME, suite.getName());
    // Calculate the duration
    Map<String, ISuiteResult> results = suite.getResults();
    Date minStartDate = new Date();
    Date maxEndDate = null;
    // TODO: We could probably optimize this in order not to traverse this twice
    for (Map.Entry<String, ISuiteResult> result : results.entrySet()) {
        ITestContext testContext = result.getValue().getTestContext();
        Date startDate = testContext.getStartDate();
        Date endDate = testContext.getEndDate();
        if (minStartDate.after(startDate)) {
            minStartDate = startDate;
        }
        if (maxEndDate == null || maxEndDate.before(endDate)) {
            maxEndDate = endDate != null ? endDate : startDate;
        }
    }
    // The suite could be completely empty
    if (maxEndDate == null) {
        maxEndDate = minStartDate;
    }
    addDurationAttributes(config, props, minStartDate, maxEndDate);
    return props;
}
Also used : ITestContext(org.testng.ITestContext) Properties(java.util.Properties) ISuiteResult(org.testng.ISuiteResult) Map(java.util.Map) Date(java.util.Date)

Aggregations

ITestContext (org.testng.ITestContext)7 ISuiteResult (org.testng.ISuiteResult)5 ISuite (org.testng.ISuite)4 Properties (java.util.Properties)3 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 Date (java.util.Date)1 Map (java.util.Map)1 ITestResult (org.testng.ITestResult)1 XMLStringBuffer (org.testng.reporters.XMLStringBuffer)1