Package org.uncommons.reportng
Class ReportNGUtils
- java.lang.Object
-
- org.uncommons.reportng.ReportNGUtils
-
public class ReportNGUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ReportNGUtils()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringescapeHTMLString(java.lang.String s)Works likeescapeString(String)but also replaces line breaks with <br /> tags and preserves significant whitespace.java.lang.StringescapeString(java.lang.String s)Replace any angle brackets, quotes, apostrophes or ampersands with the corresponding XML/HTML entities to avoid problems displaying the String in an XML document.java.lang.StringformatDuration(long elapsed)java.lang.StringformatDuration(long startMillis, long endMillis)java.lang.StringformatPercentage(int numerator, int denominator)java.util.List<java.lang.String>getAllOutput()Retieves the output from all calls toReporter.log(String)across all tests.java.lang.StringgetArguments(org.testng.ITestResult result)java.util.List<java.lang.Throwable>getCauses(java.lang.Throwable t)Convert a Throwable into a list containing all of its causes.java.lang.StringgetDependentGroups(org.testng.ITestResult result)java.lang.StringgetDependentMethods(org.testng.ITestResult result)longgetDuration(org.testng.ITestContext context)Returns the aggregate of the elapsed times for each name result.longgetEndTime(org.testng.ISuite suite, org.testng.IInvokedMethod method, java.util.List<org.testng.IInvokedMethod> methods)java.lang.StringgetSkipExceptionMessage(org.testng.ITestResult result)longgetStartTime(java.util.List<org.testng.IInvokedMethod> methods)Find the earliest start time of the specified methods.java.util.List<java.lang.String>getTestOutput(org.testng.ITestResult result)Retrieves all log messages associated with a particular name result.booleanhasArguments(org.testng.ITestResult result)booleanhasDependentGroups(org.testng.ITestResult result)booleanhasDependentMethods(org.testng.ITestResult result)booleanhasGroups(org.testng.ISuite suite)booleanhasSkipException(org.testng.ITestResult result)java.lang.StringstripThreadName(java.lang.String threadId)TestNG returns a compound thread ID that includes the thread name and its numeric ID, separated by an 'at' sign.
-
-
-
Method Detail
-
getDuration
public long getDuration(org.testng.ITestContext context)
Returns the aggregate of the elapsed times for each name result.- Parameters:
context- The name results.- Returns:
- The sum of the name durations.
-
formatDuration
public java.lang.String formatDuration(long startMillis, long endMillis)
-
formatDuration
public java.lang.String formatDuration(long elapsed)
-
getCauses
public java.util.List<java.lang.Throwable> getCauses(java.lang.Throwable t)
Convert a Throwable into a list containing all of its causes.- Parameters:
t- The throwable for which the causes are to be returned.- Returns:
- A (possibly empty) list of
Throwables.
-
getTestOutput
public java.util.List<java.lang.String> getTestOutput(org.testng.ITestResult result)
Retrieves all log messages associated with a particular name result.- Parameters:
result- Which name result to look-up.- Returns:
- A list of log messages.
-
getAllOutput
public java.util.List<java.lang.String> getAllOutput()
Retieves the output from all calls toReporter.log(String)across all tests.- Returns:
- A (possibly empty) list of log messages.
-
hasArguments
public boolean hasArguments(org.testng.ITestResult result)
-
getArguments
public java.lang.String getArguments(org.testng.ITestResult result)
-
hasDependentGroups
public boolean hasDependentGroups(org.testng.ITestResult result)
- Parameters:
result- The name result to be checked for dependent groups.- Returns:
- True if this name was dependent on any groups, false otherwise.
-
getDependentGroups
public java.lang.String getDependentGroups(org.testng.ITestResult result)
- Parameters:
result- The name result to be checked for dependent groups.- Returns:
- A comma-separated string listing all dependent groups. Returns an empty string it there are no dependent groups.
-
hasDependentMethods
public boolean hasDependentMethods(org.testng.ITestResult result)
- Parameters:
result- The name result to be checked for dependent methods.- Returns:
- True if this name was dependent on any methods, false otherwise.
-
getDependentMethods
public java.lang.String getDependentMethods(org.testng.ITestResult result)
- Parameters:
result- The name result to be checked for dependent methods.- Returns:
- A comma-separated string listing all dependent methods. Returns an empty string it there are no dependent methods.
-
hasSkipException
public boolean hasSkipException(org.testng.ITestResult result)
-
getSkipExceptionMessage
public java.lang.String getSkipExceptionMessage(org.testng.ITestResult result)
-
hasGroups
public boolean hasGroups(org.testng.ISuite suite)
-
escapeString
public java.lang.String escapeString(java.lang.String s)
Replace any angle brackets, quotes, apostrophes or ampersands with the corresponding XML/HTML entities to avoid problems displaying the String in an XML document. Assumes that the String does not already contain any entities (otherwise the ampersands will be escaped again).- Parameters:
s- The String to escape.- Returns:
- The escaped String.
-
escapeHTMLString
public java.lang.String escapeHTMLString(java.lang.String s)
Works likeescapeString(String)but also replaces line breaks with <br /> tags and preserves significant whitespace.- Parameters:
s- The String to escape.- Returns:
- The escaped String.
-
stripThreadName
public java.lang.String stripThreadName(java.lang.String threadId)
TestNG returns a compound thread ID that includes the thread name and its numeric ID, separated by an 'at' sign. We only want to use the thread name as the ID is mostly unimportant and it takes up too much space in the generated report.- Parameters:
threadId- The compound thread ID.- Returns:
- The thread name.
-
getStartTime
public long getStartTime(java.util.List<org.testng.IInvokedMethod> methods)
Find the earliest start time of the specified methods.- Parameters:
methods- A list of name methods.- Returns:
- The earliest start time.
-
getEndTime
public long getEndTime(org.testng.ISuite suite, org.testng.IInvokedMethod method, java.util.List<org.testng.IInvokedMethod> methods)
-
formatPercentage
public java.lang.String formatPercentage(int numerator, int denominator)
-
-