Top Description Fields Constructors Methods
org.testng

public Class Reporter

extends Object
Class Inheritance
Imports
java.util.LinkedList, .List, .Map, org.testng.collections.Lists, .Maps, org.testng.internal.AutoCloseableLock, .Utils, org.testng.util.Strings

This class is used for test methods to log messages that will be included in the HTML reports generated by TestNG.

Implementation details

The reporter keeps a combined output of strings (in m_output) and also a record of which method output which line. In order to do this, callers specify what the current method is with setCurrentTestResult() and the Reporter maintains a mapping of each test result with a list of integers. These integers are indices in the combined output (avoids duplicating the output).

Created on Nov 2, 2005

Author
cbeust

Field Summary

Modifier and TypeField and Description
private static final AutoCloseableLock
private static final AutoCloseableLock
private static final ThreadLocal<ITestResult>
private static boolean
private static final Map<String, List<Integer>>
private static final ThreadLocal<List<String>>
private static final List<String>
m_output

All output logged in a sequential order.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
clear()

Erase the content of all the output generated so far.

public static ITestResult

Returns:

the current test result.
getCurrentTestResult
()

public static boolean

Returns:

If true, use HTML entities for special HTML characters (<, >, &, ...).
getEscapeHtml
()

public static List<String>
public static List<String>
private static List<String>
private static void
public static void
log(String
The message to log
s
)

Log the passed string to the HTML reports.

public static void
log(String
The message to log
s
,
int
The verbosity of this message
level
,
boolean
Whether to print this string on standard out too
logToStandardOut
)

Log the passed string to the HTML reports if the current verbosity is equal to or greater than the one passed as a parameter.

public static void
log(String
The message to log
s
,
boolean
Whether to print this string on standard out too
logToStandardOut
)

Log the passed string to the HTML reports.

public static void
log(String
The message to log
s
,
int
The verbosity of this message
level
)

Log the passed string to the HTML reports if the current verbosity is equal to or greater than the one passed as a parameter.

private static void
public static void
public static void
setEscapeHtml(boolean
If true, use HTML entities for special HTML characters (<, >, &, ...).
escapeHtml
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lockForLoggingback to summary
private static final AutoCloseableLock lockForLogging
lockForOutputsback to summary
private static final AutoCloseableLock lockForOutputs
m_currentTestResultback to summary
private static final ThreadLocal<ITestResult> m_currentTestResult
m_escapeHtmlback to summary
private static boolean m_escapeHtml
m_methodOutputMapback to summary
private static final Map<String, List<Integer>> m_methodOutputMap
m_orphanedOutputback to summary
private static final ThreadLocal<List<String>> m_orphanedOutput
m_outputback to summary
private static final List<String> m_output

All output logged in a sequential order.

Constructor Detail

Reporterback to summary
public Reporter()

Method Detail

clearback to summary
public static void clear()

Erase the content of all the output generated so far.

getCurrentTestResultback to summary
public static ITestResult getCurrentTestResult()
Returns:ITestResult

the current test result.

getEscapeHtmlback to summary
public static boolean getEscapeHtml()
Returns:boolean

If true, use HTML entities for special HTML characters (<, >, &, ...).

getOutputback to summary
public static List<String> getOutput()
getOutputback to summary
public static List<String> getOutput(ITestResult tr)
getOutputFromResultback to summary
private static List<String> getOutputFromResult(ITestResult tr)
logback to summary
private static void log(String s, ITestResult m)
logback to summary
public static void log(String s)

Log the passed string to the HTML reports.

Parameters
s:String

The message to log

logback to summary
public static void log(String s, int level, boolean logToStandardOut)

Log the passed string to the HTML reports if the current verbosity is equal to or greater than the one passed as a parameter. If logToStandardOut is true, the string will also be printed on standard out.

Parameters
s:String

The message to log

level:int

The verbosity of this message

logToStandardOut:boolean

Whether to print this string on standard out too

logback to summary
public static void log(String s, boolean logToStandardOut)

Log the passed string to the HTML reports. If logToStandardOut is true, the string will also be printed on standard out.

Parameters
s:String

The message to log

logToStandardOut:boolean

Whether to print this string on standard out too

logback to summary
public static void log(String s, int level)

Log the passed string to the HTML reports if the current verbosity is equal to or greater than the one passed as a parameter.

Parameters
s:String

The message to log

level:int

The verbosity of this message

logToReportsback to summary
private static void logToReports(String s, ITestResult m)
setCurrentTestResultback to summary
public static void setCurrentTestResult(ITestResult m)
setEscapeHtmlback to summary
public static void setEscapeHtml(boolean escapeHtml)
Parameters
escapeHtml:boolean

If true, use HTML entities for special HTML characters (<, >, &, ...).