문제

I was curious to know what the default listeners are in TestNG. I saw a bool property on the Ant task for useDefaultListeners but I would like to know what these are and where I can find them.

도움이 되었습니까?

해결책

There are four default reporters:

http://code.google.com/p/testng/source/browse/trunk/src/org/testng/reporters/SuiteHTMLReporter.java

The main reporter that creates the HTML reports.

http://code.google.com/p/testng/source/browse/trunk/src/org/testng/reporters/FailedReporter.java

This reporter creates testng-failed.xml

http://code.google.com/p/testng/source/browse/trunk/src/org/testng/reporters/XMLReporter.java

This reporter generates an XML file that captures the entire description of this test run. This XML file is used by other tools for further generation (PDF, etc...).

http://code.google.com/p/testng/source/browse/trunk/src/org/testng/reporters/EmailableReporter.java

This reporter creates a file that is suitable to be emailed either attached or inline.

Hope this helps.

--
Cedric

다른 팁

These seem to change every so often. The answer seems to be to look in the source code - initializeDefaultListeners()

private void initializeDefaultListeners() {
  m_testListeners.add(new ExitCodeListener(this));
  if (m_useDefaultListeners) {
    addReporter(SuiteHTMLReporter.class);
    addReporter(FailedReporter.class);
    addReporter(XMLReporter.class);
    addReporter(EmailableReporter.class);
    addReporter(JUnitReportReporter.class);
  }
}

When I experimented with altering this (to remove SuiteHTMLReporter), it was important to retain the difference between listeners and reporters, and to retain the order of the reporters.

There is (at least) one quite useful reporter missing:

  • org.testng.reporters.TestHTMLReporter

The reporter creates the suitename/suitename.html which is linked in the html reporter result at the "results" link on the left side.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top