Java 类org.testng.ISuiteResult 实例源码

项目:sunshine    文件:TestNGStatus.java   
private void calculate() {
    if (!this.counts.isEmpty()) return;
    int passed = 0;
    int failed = 0;
    int skipped = 0;

    for (ISuite suite : this.reports) {
        for (ISuiteResult result : suite.getResults().values()) {
            final ITestContext testContext = result.getTestContext();
            passed += testContext.getPassedTests().size();
            failed += testContext.getFailedTests().size();
            skipped += testContext.getSkippedTests().size();
        }
    }
    this.counts.add(0, passed + failed + skipped);
    this.counts.add(1, failed);
    this.counts.add(2, skipped);
}
项目:webUIAuto    文件:PowerEmailableReporter.java   
/** 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());
        }
    }
}
项目:WebAndAppUITesting    文件:PowerEmailableReporter.java   
/** 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());
        }
    }
}
项目:oldmonk    文件:ReporterAPI.java   
public List<String> getAllTestNames()
{
    List<String> allTestNames = new ArrayList<String>();

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();
        parallelRunParam = suite.getParallel();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            allTestNames.add(r.getTestContext().getName());
        }
    }

    return allTestNames;
}
项目:oldmonk    文件:ReporterAPI.java   
public int getTotalPassedMethodsForSuite()
{
    int totalNumberOfPassedMethodsForSuite = 0;

    ITestContext overview = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            totalNumberOfPassedMethodsForSuite += overview.getPassedTests().getAllMethods().size();
        }
    }

    return totalNumberOfPassedMethodsForSuite;
}
项目:oldmonk    文件:ReporterAPI.java   
public int getTotalFailedMethodsForSuite()
{
    int totalNumberOfFailedMethodsForSuite = 0;

    ITestContext overview = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            totalNumberOfFailedMethodsForSuite += overview.getFailedTests().getAllMethods().size();
        }
    }

    return totalNumberOfFailedMethodsForSuite;
}
项目:oldmonk    文件:ReporterAPI.java   
public int getTotalSkippedMethodsForSuite()
{
    int totalNumberOfSkippedMethodsForSuite = 0;

    ITestContext overview = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            totalNumberOfSkippedMethodsForSuite += overview.getSkippedTests().getAllMethods().size();
        }
    }

    return totalNumberOfSkippedMethodsForSuite;
}
项目:oldmonk    文件:ReporterAPI.java   
public int getTotalPassedMethodsForTest(final String testName)
{
    int totalNumberOfPassedMethodsForTest = 0;

    ITestContext overview = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (testName.equalsIgnoreCase(overview.getName()))
            {
                totalNumberOfPassedMethodsForTest = overview.getPassedTests().getAllMethods().size();
                break;
            }
        }
    }

    return totalNumberOfPassedMethodsForTest;
}
项目:oldmonk    文件:ReporterAPI.java   
public int getTotalFailedMethodsForTest(String testName)
{
    int totalNumberOfFailedMethodsForTest = 0;

    ITestContext overview = null;

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (testName.equalsIgnoreCase(overview.getName()))
            {
                totalNumberOfFailedMethodsForTest = overview.getFailedTests().getAllMethods().size();
                break;
            }
        }
    }

    return totalNumberOfFailedMethodsForTest;
}
项目:oldmonk    文件:ReporterAPI.java   
public int getTotalSkippedMethodsForTest(final String testName)
{
    int totalNumberOfSkippedMethodsForTest = 0;
    ITestContext overview = null;

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();
            if (testName.equalsIgnoreCase(overview.getName()))
            {
                totalNumberOfSkippedMethodsForTest = overview.getSkippedTests().getAllMethods().size();
                break;
            }
        }
    }

    return totalNumberOfSkippedMethodsForTest;
}
项目:oldmonk    文件:ReporterAPI.java   
public Map<String, String> getAllParametersForTest(String testName)
{
    ITestContext overview = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (testName.equalsIgnoreCase(overview.getName()))
            {
                return overview.getCurrentXmlTest().getAllParameters();
            }
        }
    }

    return null;
}
项目:oldmonk    文件:ReporterAPI.java   
public String getParameterValueForTest(String testName, String parameter)
{
    ITestContext overview = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (testName.equalsIgnoreCase(overview.getName()))
            {
                return overview.getCurrentXmlTest().getParameter(parameter);
            }
        }
    }

    return null;
}
项目:oldmonk    文件:ReporterAPI.java   
public ITestNGMethod[] getAllMethodsForTest(String testName)
{
    ITestContext overview = null;

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (overview.getName().equalsIgnoreCase(testName))
            {
                return overview.getAllTestMethods();
            }
        }
    }

    return null;
}
项目:DolphinNG    文件:EmailableReporter.java   
/**
 * Creates a table showing the highlights of each test method with links to the method details
 */
protected void generateMethodSummaryReport(List<ISuite> suites)
{
    m_methodIndex = 0;
    m_out.println("<a id=\"summary\"></a>");
    startResultSummaryTable("passed");
    for (ISuite suite : suites)
    {
        if (suites.size() > 1)
        {
            titleRow(suite.getName(), 4);
        }
        Map<String, ISuiteResult> r = suite.getResults();
        for (ISuiteResult r2 : r.values())
        {
            ITestContext testContext = r2.getTestContext();
            String testName = testContext.getName();
            resultSummary(testContext.getFailedConfigurations(), testName, "failed", " (configuration methods)");
            resultSummary(testContext.getFailedTests(), testName, "failed", "");
            resultSummary(testContext.getSkippedConfigurations(), testName, "skipped", " (configuration methods)");
            resultSummary(testContext.getSkippedTests(), testName, "skipped", "");
            resultSummary(testContext.getPassedTests(), testName, "passed", "");
        }
    }
    m_out.println("</table>");
}
项目:DolphinNG    文件:EmailableReporter.java   
/**
 * Creates a section showing known results for each method
 */
protected void generateMethodDetailReport(List<ISuite> suites)
{
    m_methodIndex = 0;
    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(), "failed");
            resultDetail(testContext.getFailedTests(), "failed");
            resultDetail(testContext.getSkippedConfigurations(), "skipped");
            resultDetail(testContext.getSkippedTests(), "skipped");
            resultDetail(testContext.getPassedTests(), "passed");
        }
    }
}
项目:selenium-testng-template    文件:HtmlReporter.java   
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    StringBuilder sb = new StringBuilder();
    for (ISuite suite : suites) {
        Map<String, ISuiteResult> results = suite.getResults();
        for (Map.Entry<String, ISuiteResult> result : results.entrySet()) {
            String report = buildReport(result.getValue().getTestContext());
            sb.append(report);
        }
    }
    try {
        FileUtils.writeToFile(new File(FAILED_REPORT_FILE), sb.toString());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:cashion    文件:IReporterNewReport.java   
@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));
        }          
    }
    this.sort(list);
    this.outputResult(list, outputDirectory+"/test.txt");
}
项目:webUIAuto    文件:PowerEmailableReporter.java   
/**
 * 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>");
}
项目:AppiumTestDistribution    文件:AppiumParallelTestListener.java   
private JSONObject getSummaryDetails(Map<String, ISuiteResult> results) {

        Object firstSuite = results.keySet().toArray()[0];
        ISuiteResult result = results.get(firstSuite);
        ITestContext testContext = result.getTestContext();
        int passedTests = testContext.getPassedTests().getAllResults().size();
        int failedTests = testContext.getFailedTests().getAllResults().size();
        int skippedTests = testContext.getSkippedTests().getAllResults().size();
        String suiteName = testContext.getName();
        //String includedGroups = testContext.getIncludedGroups().toString();

        JSONObject jsonSummary = new JSONObject();
        jsonSummary.put("suite_name", suiteName);
        //jsonSummary.put("Included Groups", includedGroups);
        jsonSummary.put("passed", passedTests);
        jsonSummary.put("failed", failedTests);
        jsonSummary.put("skipped", skippedTests);
        jsonSummary.put("duration", Duration.of(testContext.getEndDate().getTime()
                - testContext.getStartDate().getTime(), ChronoUnit.SECONDS));

        return jsonSummary;
    }
项目:wtf-core    文件:BaseListener.java   
private void logAllValidFailuresToPipline(java.util.List<ISuite> suites) {
  //Reporter.startRun(runId);
  for (ISuite suite : suites) {
    for (ISuiteResult result : suite.getResults().values()) {
      for (ITestResult failedResult : result.getTestContext().getFailedTests().getAllResults()){
        if (failedResult.getAttribute("RETRY") != null) {
          continue;
        }
        String browser = getBrowserName(failedResult);
        String site = getSiteName(failedResult);
        LOG(Level.SEVERE, String.format("[STACK TARCE] for [%s] [%s]%s \n %s",
                                        browser,
                                        site,
                                        getTestMethodNameinPackageStyle(failedResult),
                                        getDetailedStackTrace(failedResult)));
        logResultsToPipeline(failedResult);
      }
    }
  }
}
项目:wtf-core    文件:BaseListener.java   
public void generateConsolidatedReportByOwner(java.util.List<XmlSuite> xmlSuites,
    java.util.List<ISuite> suites, java.lang.String outputDirectory) {

  Map<String, List<ITestResult>> ownersOfFailedTests = new HashMap<String, List<ITestResult>>();
  Map<String, List<ITestResult>> ownersOfPassedTests = new HashMap<String, List<ITestResult>>();

  for (ISuite suite : suites) {
    for (ISuiteResult result : suite.getResults().values()) {
      ownersOfPassedTests = getTestByOwnerSiteBrowser(result.getTestContext().getPassedTests().getAllResults());
      ownersOfFailedTests = getTestByOwnerSiteBrowser(result.getTestContext().getFailedTests().getAllResults());
    }
  }

  // Send consolidated failures to the Team group email id.
  TestNGEmailSender.sendConsolidatedFailureEmail(ownersOfPassedTests, ownersOfFailedTests);
}
项目:gga-selenium-framework    文件:JUnitXMLReporter.java   
/**
 * Flatten a list of test suite results into a collection of results grouped by test class.
 * This method basically strips away the TestNG way of organising tests and arranges
 * the results by test class.
 */
private Collection<TestClassResults> flattenResults(List<ISuite> suites) {
    Map<IClass, TestClassResults> flattenedResults = new HashMap<>();
    for (ISuite suite : suites) {
        for (ISuiteResult suiteResult : suite.getResults().values()) {
            // Failed and skipped configuration methods are treated as test failures.
            organiseByClass(suiteResult.getTestContext().getFailedConfigurations().getAllResults(), flattenedResults);
            organiseByClass(suiteResult.getTestContext().getSkippedConfigurations().getAllResults(), flattenedResults);
            // Successful configuration methods are not included.

            organiseByClass(suiteResult.getTestContext().getFailedTests().getAllResults(), flattenedResults);
            organiseByClass(suiteResult.getTestContext().getSkippedTests().getAllResults(), flattenedResults);
            organiseByClass(suiteResult.getTestContext().getPassedTests().getAllResults(), flattenedResults);
        }
    }
    return flattenedResults.values();
}
项目:teamengine    文件:TestRunSummary.java   
/**
 * Reads the test results and extracts summary information. Each entry in
 * the results corresponds to a test set (conformance class).
 * 
 * @param results
 *            The results for all test sets that were executed.
 */
void summarizeResults(Map<String, ISuiteResult> results) {
    Date earliestStartDate = new Date();
    Date latestEndDate = new Date();
    for (Map.Entry<String, ISuiteResult> entry : results.entrySet()) {
        ITestContext testContext = entry.getValue().getTestContext();
        this.totalPassed += testContext.getPassedTests().size();
        this.totalFailed += testContext.getFailedTests().size();
        this.totalSkipped += testContext.getSkippedTests().size();
        Date startDate = testContext.getStartDate();
        if (earliestStartDate.after(startDate)) {
            earliestStartDate = startDate;
        }
        Date endDate = testContext.getEndDate();
        if (latestEndDate.before(endDate)) {
            latestEndDate = (endDate != null) ? endDate : startDate;
        }
    }
    this.totalDuration = Duration.between(earliestStartDate.toInstant(), latestEndDate.toInstant());
}
项目:teamengine    文件:EarlReporter.java   
/**
 * Creates EARL statements for the entire collection of test suite results.
 * Each test subset is defined by a {@literal <test>} tag in the suite
 * definition; these correspond to earl:TestRequirement resources in the
 * model.
 * 
 * @param model
 *            An RDF Model containing EARL statements.
 * @param results
 *            A Map containing the actual test results, where the key is the
 *            name of a test subset (conformance class).
 */
void processSuiteResults(Model model, Map<String, ISuiteResult> results) {
    for (Map.Entry<String, ISuiteResult> entry : results.entrySet()) {
        String testReqName = entry.getKey().replaceAll("\\s", "-");
        // can return existing resource in model
        Resource testReq = model.createResource(testReqName);
        ITestContext testContext = entry.getValue().getTestContext();
        int nPassed = testContext.getPassedTests().size();
        int nSkipped = testContext.getSkippedTests().size();
        int nFailed = testContext.getFailedTests().size();
        testReq.addLiteral(CITE.testsPassed, new Integer(nPassed));
        testReq.addLiteral(CITE.testsFailed, new Integer(nFailed));
        testReq.addLiteral(CITE.testsSkipped, new Integer(nSkipped));
        if (nPassed + nFailed == 0) {
            testReq.addProperty(DCTerms.description,
                    "A precondition was not met. All tests in this set were skipped.");
        }
        processTestResults(model, testContext.getFailedTests());
        processTestResults(model, testContext.getSkippedTests());
        processTestResults(model, testContext.getPassedTests());
    }
}
项目:WebAndAppUITesting    文件:PowerEmailableReporter.java   
/**
 * 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>");
}
项目:PatatiumWebUi    文件:TestReport.java   
@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");


}
项目:agent-java-testNG    文件:BuildTestTest.java   
@Test
public void testFinishSuiteFailed() {
    ISuiteResult suiteResult = mock(ISuiteResult.class);
    Map<String, ISuiteResult> suiteResults = new HashMap<String, ISuiteResult>(1);
    suiteResults.put("", suiteResult);
    IResultMap resultMap = mock(ResultMap.class);

    when(iSuite.getResults()).thenReturn(suiteResults);
    when(suiteResult.getTestContext()).thenReturn(testContext);
    when(testContext.getFailedTests()).thenReturn(resultMap);
    when(resultMap.size()).thenReturn(1);

    FinishTestItemRQ rq = testNGService.buildFinishTestSuiteRq(iSuite);
    assertThat(rq.getStatus(), is(Statuses.FAILED));
}
项目:automation-test-engine    文件:ATEXMLReporter.java   
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites,
        String outputDirectory) {
    if (Utils.isStringEmpty(config.getOutputDirectory())) {
        config.setOutputDirectory(outputDirectory);
    }

    // Calculate passed/failed/skipped
    int passed = 0;
    int failed = 0;
    int skipped = 0;
    for (ISuite s : suites) {
        for (ISuiteResult sr : s.getResults().values()) {
            ITestContext testContext = sr.getTestContext();
            passed += testContext.getPassedTests().size();
            failed += testContext.getFailedTests().size();
            skipped += testContext.getSkippedTests().size();
        }
    }

    rootBuffer = new XMLStringBuffer();
    Properties p = new Properties();
    p.put("passed", passed);
    p.put("failed", failed);
    p.put("skipped", skipped);
    p.put("total", passed + failed + skipped);
    rootBuffer.push(XMLReporterConfig.TAG_TESTNG_RESULTS, p);
    writeReporterOutput(rootBuffer);
    for (int i = 0; i < suites.size(); i++) {
        writeSuite(suites.get(i).getXmlSuite(), suites.get(i));
    }
    rootBuffer.pop();
    Utils.writeUtf8File(config.getOutputDirectory(), FILE_NAME, rootBuffer,
            null /* no prefix */);
}
项目:automation-test-engine    文件:ATEXMLReporter.java   
private void writeSuiteToBuffer(XMLStringBuffer xmlBuffer, ISuite suite) {
    xmlBuffer.push(XMLReporterConfig.TAG_SUITE, getSuiteAttributes(suite));
    writeSuiteGroups(xmlBuffer, suite);

    Map<String, ISuiteResult> results = suite.getResults();
    ATEXMLSuiteResultWriter suiteResultWriter = new ATEXMLSuiteResultWriter(
            config);
    for (Map.Entry<String, ISuiteResult> result : results.entrySet()) {
        suiteResultWriter.writeSuiteResult(xmlBuffer, result.getValue());
    }

    xmlBuffer.pop();
}
项目:automation-test-engine    文件:ATEXMLReporter.java   
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;
}
项目:automation-test-engine    文件:ATEXMLSuiteResultWriter.java   
/**
* Writes the specified ISuiteResult in the given XMLStringBuffer. Please consider that depending on the settings in
* the <code>config</code> property it might generate an additional XML file with the actual content and only
* reference the file with an <code>url</code> attribute in the passed XMLStringBuffer.
*
* @param xmlBuffer The XML buffer where to write or reference the suite result
* @param suiteResult The <code>ISuiteResult</code> to serialize
*/
  public void writeSuiteResult(XMLStringBuffer xmlBuffer, ISuiteResult suiteResult) {
    if (XMLReporterConfig.FF_LEVEL_SUITE_RESULT != config.getFileFragmentationLevel()) {
      writeAllToBuffer(xmlBuffer, suiteResult);
    } else {
      String parentDir =
              config.getOutputDirectory() + File.separatorChar + suiteResult.getTestContext().getSuite().getName();
      File file = referenceSuiteResult(xmlBuffer, parentDir, suiteResult);
      XMLStringBuffer suiteXmlBuffer = new XMLStringBuffer();
      writeAllToBuffer(suiteXmlBuffer, suiteResult);
      Utils.writeUtf8File(file.getAbsoluteFile().getParent(), file.getName(), suiteXmlBuffer.toXML());
    }
  }
项目:automation-test-engine    文件:ATEXMLSuiteResultWriter.java   
private void writeAllToBuffer(XMLStringBuffer xmlBuffer, ISuiteResult suiteResult) {
  xmlBuffer.push(XMLReporterConfig.TAG_TEST, getSuiteResultAttributes(suiteResult));
  Set<ITestResult> testResults = Sets.newHashSet();
  ITestContext testContext = suiteResult.getTestContext();
  addAllTestResults(testResults, testContext.getPassedTests());
  addAllTestResults(testResults, testContext.getFailedTests());
  addAllTestResults(testResults, testContext.getSkippedTests());
  addAllTestResults(testResults, testContext.getPassedConfigurations());
  addAllTestResults(testResults, testContext.getSkippedConfigurations());
  addAllTestResults(testResults, testContext.getFailedConfigurations());
  addAllTestResults(testResults, testContext.getFailedButWithinSuccessPercentageTests());
  addTestResults(xmlBuffer, testResults);
  xmlBuffer.pop();
}
项目:automation-test-engine    文件:ATEXMLSuiteResultWriter.java   
private File referenceSuiteResult(XMLStringBuffer xmlBuffer, String parentDir, ISuiteResult suiteResult) {
  Properties attrs = new Properties();
  String suiteResultName = suiteResult.getTestContext().getName() + ".xml";
  attrs.setProperty(XMLReporterConfig.ATTR_URL, suiteResultName);
  xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_TEST, attrs);
  return new File(parentDir + File.separatorChar + suiteResultName);
}
项目:automation-test-engine    文件:ATEXMLSuiteResultWriter.java   
private Properties getSuiteResultAttributes(ISuiteResult suiteResult) {
  Properties attributes = new Properties();
  ITestContext tc = suiteResult.getTestContext();
  attributes.setProperty(XMLReporterConfig.ATTR_NAME, tc.getName());
  ATEXMLReporter.addDurationAttributes(config, attributes, tc.getStartDate(), tc.getEndDate());
  return attributes;
}
项目:WebAndAppUITesting    文件:PowerEmailableReporter.java   
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>");
}
项目:oldmonk    文件:ReporterAPI.java   
public List<String> getIncludedModulesForTest(String testName)
{
    ITestContext overview = null;

    List<String> includedModules = new ArrayList<String>();
    String includedModule = "";
    String modulesCommaSeparated = config.getProperty("application.modules").replaceAll("\\s+", "");

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (overview.getName().equalsIgnoreCase(testName))
            {
                String[] allDefinedModules = null;

                if (modulesCommaSeparated == null || modulesCommaSeparated.trim().length() == 0)
                {
                    Assert.fail("ERROR - Modules are not found in properties file");
                } else
                {
                    allDefinedModules = new String[modulesCommaSeparated.length()];
                    allDefinedModules = modulesCommaSeparated.split(",");
                }

                ITestNGMethod[] allTestMethods = overview.getAllTestMethods();

                for (ITestNGMethod testngMethod : allTestMethods)
                {
                    String[] modules = testngMethod.getGroups();
                    for (String module : modules)
                    {
                        for (String moduleName : allDefinedModules)
                        {
                            if (module.equalsIgnoreCase(moduleName))
                            {
                                if (!(includedModule.contains(module)))
                                {
                                    includedModules.add(module);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return includedModules;
}
项目:oldmonk    文件:ReporterAPI.java   
public List<String> getIncludedGroupsForTest(String testName)
{
    ITestContext overview = null;

    List<String> includedGroups = new ArrayList<String>();
    String includedGroup = "";
    String groupsCommaSeparated = config.getProperty("test.groups").replaceAll("\\s+", "");

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (overview.getName().equalsIgnoreCase(testName))
            {

                String[] allDefinedGroups = null;

                if (groupsCommaSeparated == null || groupsCommaSeparated.trim().length() == 0)
                {
                    Assert.fail("ERROR - Test Groups are not found in properties file");
                } else
                {
                    allDefinedGroups = new String[groupsCommaSeparated.length()];
                    allDefinedGroups = groupsCommaSeparated.split(",");
                }

                ITestNGMethod[] allTestMethods = overview.getAllTestMethods();

                for (ITestNGMethod testngMethod : allTestMethods)
                {
                    String[] groups = testngMethod.getGroups();
                    for (String group : groups)
                    {
                        for (String groupName : allDefinedGroups)
                        {
                            if (group.equalsIgnoreCase(groupName))
                            {
                                if (!(includedGroup.contains(group)))
                                {
                                    includedGroups.add(group);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return includedGroups;
}
项目:oldmonk    文件:ReporterAPI.java   
public String getSuccessPercentageForTest(String testName)
{
    String successPercentageForTest = null;

    NumberFormat nf = NumberFormat.getInstance();

    nf.setMaximumFractionDigits(2);
    nf.setGroupingUsed(true);

    int totalPassedMethodsForTest = 0;
    int totalFailedMethodsForTest = 0;
    int totalSkippedMethodsForTest = 0;

    ITestContext overview = null;

    for (ISuite suite : suites)
    {
        suiteName = suite.getName();

        Map<String, ISuiteResult> tests = suite.getResults();

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();
            if (testName.equalsIgnoreCase(overview.getName()))
            {
                totalPassedMethodsForTest = overview.getPassedTests().getAllMethods().size();
                totalFailedMethodsForTest = overview.getFailedTests().getAllMethods().size();
                totalSkippedMethodsForTest = overview.getSkippedTests().getAllMethods().size();

                break;
            }
        }
    }

    try
    {
        successPercentageForTest = nf.format(((float) totalPassedMethodsForTest
                / (float) (totalPassedMethodsForTest + totalFailedMethodsForTest + totalSkippedMethodsForTest))
                * 100);
    } catch (NumberFormatException realCause)
    {
        LOGGER.debug(realCause.getMessage());
    }

    return successPercentageForTest;
}
项目:oldmonk    文件:ReporterAPI.java   
public Set<ITestResult> getMethodResults(final String testName, final String methodName)
{
    ITestContext overview = null;

    Set<ITestResult> testResult = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (testName.equalsIgnoreCase(overview.getName()))
            {
                ITestNGMethod[] testMethods = overview.getAllTestMethods();
                for (ITestNGMethod method : testMethods)
                {
                    if (method.getMethodName().equalsIgnoreCase(methodName))
                    {
                        if (!(overview.getPassedTests().getResults(method).isEmpty()))
                        {
                            testResult = overview.getPassedTests().getResults(method);
                            break;
                        } else if (!(overview.getFailedTests().getResults(method).isEmpty()))
                        {
                            testResult = overview.getFailedTests().getResults(method);
                            break;
                        } else if (!(overview.getSkippedTests().getResults(method).isEmpty()))
                        {
                            testResult = overview.getSkippedTests().getResults(method);
                            break;
                        }
                    }
                }
            }
        }
    }

    return testResult;
}
项目:oldmonk    文件:ReporterAPI.java   
public String getTestFailureStackTrace(final String testName, final String methodName)
{
    ITestContext overview = null;

    Set<ITestResult> testResult = null;

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

        for (ISuiteResult r : tests.values())
        {
            overview = r.getTestContext();

            if (testName.equalsIgnoreCase(overview.getName()))
            {
                ITestNGMethod[] testMethods = overview.getAllTestMethods();
                for (ITestNGMethod method : testMethods)
                {
                    if (method.getMethodName().equalsIgnoreCase(methodName))
                    {
                        if (!(overview.getPassedTests().getResults(method).isEmpty()))
                        {
                            testResult = overview.getPassedTests().getResults(method);
                        } else if (!(overview.getFailedTests().getResults(method).isEmpty()))
                        {
                            testResult = overview.getFailedTests().getResults(method);
                        } else if (!(overview.getSkippedTests().getResults(method).isEmpty()))
                        {
                            testResult = overview.getSkippedTests().getResults(method);
                        }

                        Iterator<ITestResult> it2 = testResult.iterator();

                        while (it2.hasNext())
                        {
                            ITestResult result = it2.next();
                            return generateExceptionReport(result.getThrowable(), method);
                        }
                    }
                }
            }
        }
    }

    return null;
}