Java 类org.testng.ISuite 实例源码

项目: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());
        }
    }
}
项目:ats-framework    文件:AtsReportListener.java   
@Override
public void generateReport(
                            List<XmlSuite> arg0,
                            List<ISuite> arg1,
                            String arg2 ) {

    //we just need the report format, that why we set other fields null
    ReportFormatter reportFormatter = new ReportFormatter(ReportAppender.getRuns(),
                                                          mailSubjectFormat,
                                                          null,
                                                          null,
                                                          0,
                                                          null);
    // send report by mail
    MailReportSender mailReportSender = new MailReportSender(reportFormatter.getDescription(),
                                                             reportFormatter.toHtml());
    mailReportSender.send();

}
项目: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 summary of the run
 */
public void generateReport(List<XmlSuite> xml, List<ISuite> suites, String outdir)
{
    try
    {
        m_out = createWriter(outdir);
    } catch (IOException e)
    {
        L.error("output file", e);
        return;
    }
    startHtml(m_out);
    generateSuiteSummaryReport(suites);
    generateMethodSummaryReport(suites);
    generateMethodDetailReport(suites);
    endHtml(m_out);
    m_out.flush();
    m_out.close();
}
项目: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");
}
项目:intellij-ce-playground    文件:TestNGTreeHierarchyTest.java   
@Test
public void testSkipTestMethod() throws Exception {

  final StringBuffer buf = new StringBuffer();
  final IDEATestNGRemoteListener listener = createListener(buf);
  listener.onStart((ISuite)null);
  listener.onTestSkipped(new MockTestNGResult("ATest", "testName"));
  listener.onFinish((ISuite)null);

  Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" +
                                        "\n" +
                                        "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://ATest']\n" +
                                        "\n" +
                                        "##teamcity[testStarted name='ATest.testName' locationHint='java:test://ATest.testName|[0|]']\n" +
                                        "\n" +
                                        "##teamcity[testIgnored name='ATest.testName']\n" +
                                        "\n" +
                                        "##teamcity[testFinished name='ATest.testName']\n" +
                                        "##teamcity[testSuiteFinished name='ATest']\n", StringUtil.convertLineSeparators(buf.toString()));
}
项目:intellij-ce-playground    文件:TestNGTreeHierarchyTest.java   
@Test
public void testFailureWithoutStart() throws Exception {

  final StringBuffer buf = new StringBuffer();
  final IDEATestNGRemoteListener listener = createListener(buf);
  listener.onStart((ISuite)null);
  listener.onTestFailure(new MockTestNGResult("ATest", "testName", createExceptionWithoutTrace(), ArrayUtil.EMPTY_OBJECT_ARRAY));
  listener.onFinish((ISuite)null);

  Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" +
                                        "\n" +
                                        "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://ATest']\n" +
                                        "\n" +
                                        "##teamcity[testStarted name='ATest.testName' locationHint='java:test://ATest.testName|[0|]']\n" +
                                        "##teamcity[testFailed name='ATest.testName' details='java.lang.Exception|n' error='true' message='']\n" +
                                        "\n" +
                                        "##teamcity[testFinished name='ATest.testName']\n" +
                                        "##teamcity[testSuiteFinished name='ATest']\n", StringUtil.convertLineSeparators(buf.toString()));
}
项目:intellij-ce-playground    文件:TestNGTreeHierarchyTest.java   
@Test
public void testSkipMethodAfterStartTest() throws Exception {
  final StringBuffer buf = new StringBuffer();
  final IDEATestNGRemoteListener listener = createListener(buf);
  listener.onStart((ISuite)null);
  final MockTestNGResult result = new MockTestNGResult("ATest", "testName");
  listener.onTestStart(result);
  listener.onTestSkipped(result);
  listener.onFinish((ISuite)null);

  Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" +
                                        "\n" +
                                        "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://ATest']\n" +
                                        "\n" +
                                        "##teamcity[testStarted name='ATest.testName' locationHint='java:test://ATest.testName|[0|]']\n" +
                                        "\n" +
                                        "##teamcity[testIgnored name='ATest.testName']\n" +
                                        "\n" +
                                        "##teamcity[testFinished name='ATest.testName']\n" +
                                        "##teamcity[testSuiteFinished name='ATest']\n", StringUtil.convertLineSeparators(buf.toString()));
}
项目:testng-remote    文件:RemoteTestNG6_5.java   
@Override
protected ITestRunnerFactory buildTestRunnerFactory() {
  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());
        }
        for (IConfigurationListener cl : getConfiguration().getConfigurationListeners()) {
          runner.addListener(cl);
        }

        return runner;
      }
    };
  }

  return m_customTestRunnerFactory;
}
项目:testng-remote    文件:RemoteTestNG6_10.java   
@Override
protected ITestRunnerFactory buildTestRunnerFactory() {
  if(null == m_customTestRunnerFactory) {
    m_customTestRunnerFactory= new ITestRunnerFactory() {
        @Override
        public TestRunner newTestRunner(ISuite suite, XmlTest xmlTest,
            Collection<IInvokedMethodListener> listeners, List<IClassListener> classListeners) {
          TestRunner runner =
            new TestRunner(getConfiguration(), suite, xmlTest,
                false /*skipFailedInvocationCounts */,
                listeners, classListeners);
          if (m_useDefaultListeners) {
            runner.addListener(new TestHTMLReporter());
            runner.addListener(new JUnitXMLReporter());
          }

          return runner;
        }
      };
  }

  return m_customTestRunnerFactory;
}
项目:testng-remote    文件:RemoteTestNG6_9_7.java   
@Override
protected ITestRunnerFactory buildTestRunnerFactory() {
  if(null == m_customTestRunnerFactory) {
    m_customTestRunnerFactory= new ITestRunnerFactory() {
        @Override
        public TestRunner newTestRunner(ISuite suite, XmlTest xmlTest,
            Collection<IInvokedMethodListener> listeners) {
          TestRunner runner =
            new TestRunner(getConfiguration(), suite, xmlTest,
                false /*skipFailedInvocationCounts */,
                listeners);
          if (m_useDefaultListeners) {
            runner.addListener(new TestHTMLReporter());
            runner.addListener(new JUnitXMLReporter());
          }
          for (IConfigurationListener cl : getConfiguration().getConfigurationListeners()) {
            runner.addListener(cl);
          }

          return runner;
        }
      };
  }

  return m_customTestRunnerFactory;
}
项目:testng-remote    文件:RemoteTestNG6_9_10.java   
@Override
protected ITestRunnerFactory buildTestRunnerFactory() {
  if(null == m_customTestRunnerFactory) {
    m_customTestRunnerFactory= new ITestRunnerFactory() {
        @Override
        public TestRunner newTestRunner(ISuite suite, XmlTest xmlTest,
            Collection<IInvokedMethodListener> listeners, List<IClassListener> classListeners) {
          TestRunner runner =
            new TestRunner(getConfiguration(), suite, xmlTest,
                false /*skipFailedInvocationCounts */,
                listeners, classListeners);
          if (m_useDefaultListeners) {
            runner.addListener(new TestHTMLReporter());
            runner.addListener(new JUnitXMLReporter());
          }
          for (IConfigurationListener cl : getConfiguration().getConfigurationListeners()) {
            runner.addListener(cl);
          }

          return runner;
        }
      };
  }

  return m_customTestRunnerFactory;
}
项目:testng-remote    文件:RemoteTestNG6_12.java   
@Override
protected ITestRunnerFactory buildTestRunnerFactory() {
  if(null == m_customTestRunnerFactory) {
    m_customTestRunnerFactory= new ITestRunnerFactory() {
        @Override
        public TestRunner newTestRunner(ISuite suite, XmlTest xmlTest,
            Collection<IInvokedMethodListener> listeners, List<IClassListener> classListeners) {
          TestRunner runner =
            new TestRunner(getConfiguration(), suite, xmlTest,
                false /*skipFailedInvocationCounts */,
                listeners, classListeners);
          if (m_useDefaultListeners) {
            runner.addListener(new TestHTMLReporter());
            runner.addListener(new JUnitXMLReporter());
          }

          return runner;
        }
      };
  }

  return m_customTestRunnerFactory;
}
项目:testng-remote    文件:RemoteTestNG6_0.java   
@Override
protected ITestRunnerFactory buildTestRunnerFactory() {
  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;
}
项目: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>");
}
项目:android-testng    文件:TestNGLogger.java   
@Override
public void onFinish(ITestContext context) {
    final ISuite suite = context.getSuite();
    final String suiteName = suite == null ? "[UNKNOWN]" : suite.getName();

    final IResultMap passed = context.getPassedTests();
    final IResultMap failed = context.getFailedTests();
    final IResultMap skipped = context.getSkippedTests();

    final int passedCount = passed == null ? -1 : passed.size();
    final int failedCount = failed == null ? -1 : failed.size();
    final int skippedCount = skipped == null ? -1 : skipped.size();

    Log.i(TAG, "Finished test run \"" + suiteName + "\" with "
               + passedCount + " successful tests, "
               + failedCount + " failures and "
               + skippedCount + " tests skipped");
}
项目:difido-reports    文件:RemoteDifidoReporter.java   
/**
 * Event for end of suite
 * 
 * @param suite
 */
@Override
public void onFinish(ISuite suite) {
    // TODO: Find a place to call it.

    // We are not using shared execution, that means that we are the only
    // one that are using it and we just ended with it, so let's set it to
    // not active
    if (executionId > 0 && !difidoConfig.getPropertyAsBoolean(RemoteDifidoOptions.USE_SHARED_EXECUTION)) {
        try {
            client.endExecution(executionId);
        } catch (Exception e) {
            System.out.println("Failed to close execution with id " + executionId);
        }
        executionId = -1;
    }

}
项目:difido-reports    文件:RemoteDifidoReporter.java   
public void onStart(ISuite suite) {
    super.onStart(suite);
    difidoConfig = new RemoteDifidoConfig();
    String host = null;
    int port = 0;
    try {
        enabled = Boolean.parseBoolean(difidoConfig.getPropertyAsString(RemoteDifidoOptions.ENABLED));
        if (!enabled) {
            return;
        }
        host = difidoConfig.getPropertyAsString(RemoteDifidoOptions.HOST);
        port = Integer.parseInt(difidoConfig.getPropertyAsString(RemoteDifidoOptions.PORT));
        client = new DifidoClient(host, port);
        executionId = prepareExecution();
        machineId = client.addMachine(executionId, getExecution().getLastMachine());
        enabled = true;
        log.fine(RemoteDifidoReporter.class.getName() + " was initialized successfully");
    } catch (Throwable t) {
        enabled = false;
        log.warning("Failed to init " + RemoteDifidoReporter.class.getName() + "connection with host '" + host + ":"
                + port + "' due to " + t.getMessage());
    }

}
项目:wtf-core    文件:BaseListener.java   
public synchronized void Init(ISuite suite) {
  if (runId == null) {
    String stepGuid = System.getProperty("stepguid");
    if (stepGuid != null && !stepGuid.isEmpty()) {
      BaseListener.runId = String.format("%s", stepGuid);
    } else {
      String tsGuid = System.getProperty("tsguid");
      if (tsGuid == null || stepGuid.isEmpty()) {
        tsGuid = suite.getName().replace(" ", "_");
      }
      //SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd_MMMMM_yyyy_hh_mm_aaa");

      BaseListener.runId =
          String.format("%s_%s", tsGuid,
                        FastDateFormat.getInstance("dd_MMMMM_yyyy_hh_mm_aaa").format(new Date()));
    }
  }
}
项目: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);
}
项目:automation-test-engine    文件:ATEXMLReporter.java   
private void writeSuiteGroups(XMLStringBuffer xmlBuffer, ISuite suite) {
    xmlBuffer.push(XMLReporterConfig.TAG_GROUPS);
    Map<String, Collection<ITestNGMethod>> methodsByGroups = suite
            .getMethodsByGroups();
    for (Map.Entry<String, Collection<ITestNGMethod>> entry : methodsByGroups
            .entrySet()) {
        Properties groupAttrs = new Properties();
        groupAttrs.setProperty(XMLReporterConfig.ATTR_NAME, entry.getKey());
        xmlBuffer.push(XMLReporterConfig.TAG_GROUP, groupAttrs);
        Set<ITestNGMethod> groupMethods = getUniqueMethodSet(entry
                .getValue());
        for (ITestNGMethod groupMethod : groupMethods) {
            Properties methodAttrs = new Properties();
            methodAttrs.setProperty(XMLReporterConfig.ATTR_NAME,
                    groupMethod.getMethodName());
            methodAttrs.setProperty(XMLReporterConfig.ATTR_METHOD_SIG,
                    groupMethod.toString());
            methodAttrs.setProperty(XMLReporterConfig.ATTR_CLASS,
                    groupMethod.getRealClass().getName());
            xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_METHOD,
                    methodAttrs);
        }
        xmlBuffer.pop();
    }
    xmlBuffer.pop();
}
项目:gga-selenium-framework    文件:JUnitXMLReporter.java   
/**
 * Generates a set of XML files (JUnit format) that contain data about the
 * outcome of the specified test suites.
 *
 * @param suites              Data about the test runs.
 * @param outputDirectoryName The directory in which to create the report.
 */
public void generateReport(List<XmlSuite> xmlSuites,
                           List<ISuite> suites,
                           String outputDirectoryName) {
    removeEmptyDirectories(new File(outputDirectoryName));

    File outputDirectory = new File(outputDirectoryName, REPORT_DIRECTORY);
    outputDirectory.mkdirs();

    Collection<TestClassResults> flattenedResults = flattenResults(suites);

    for (TestClassResults results : flattenedResults) {
        VelocityContext context = createContext();
        context.put(RESULTS_KEY, results);

        try {
            generateFile(new File(outputDirectory, results.getTestClass().getName() + '_' + RESULTS_FILE),
                    RESULTS_FILE + TEMPLATE_EXTENSION,
                    context);
        } catch (Exception | AssertionError ex) {
            throw new ReportNGException("Failed generating JUnit XML report.", ex);
        }
    }
}
项目: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();
}
项目:carina    文件:HealthCheckListener.java   
@Override
public void onStart(ISuite suite) {
    String healthCheckClass = Configuration.get(Parameter.HEALTH_CHECK_CLASS);
    if (suite.getParameter(Parameter.HEALTH_CHECK_CLASS.getKey()) != null) {
        // redefine by suite arguments as they have higher priority
        healthCheckClass = suite.getParameter(Parameter.HEALTH_CHECK_CLASS.getKey());
    }

    String healthCheckMethods = Configuration.get(Parameter.HEALTH_CHECK_METHODS);
    if (suite.getParameter(Parameter.HEALTH_CHECK_METHODS.getKey()) != null) {
        // redefine by suite arguments as they have higher priority
        healthCheckMethods = suite.getParameter(Parameter.HEALTH_CHECK_METHODS.getKey());
    }

    String[] healthCheckMethodsArray = null;
    if (!healthCheckMethods.isEmpty()) {
        healthCheckMethodsArray = healthCheckMethods.split(",");
    }
    checkHealth(suite, healthCheckClass, healthCheckMethodsArray);
}
项目:Reer    文件:TestNGTestClassProcessor.java   
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
    ISuite suite = context.getSuite();
    List<IMethodInstance> filtered = new LinkedList<IMethodInstance>();
    for (IMethodInstance candidate : methods) {
        if (matcher.matchesTest(candidate.getMethod().getTestClass().getName(), candidate.getMethod().getMethodName())
            || matcher.matchesTest(suite.getName(), null)) {
            filtered.add(candidate);
        }
    }
    return filtered;
}