English 中文(简体)
What are the default listeners in TestNG, and where do I find this list?
原标题:

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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签