public final class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static char |
CHAR_REPLACEMENT |
static char |
UNICODE_REPLACEMENT |
Modifier and Type | Method and Description |
---|---|
static String |
annotationFormFor(ITestNGMethod method)
Given a TestNG method, returns the corresponding annotation based on the method type
|
static String |
arrayToString(String[] strings) |
static int |
calculateInvokedMethodCount(ITestNGMethod[] methods) |
static int |
calculateInvokedMethodCount(List<ITestNGMethod> methods) |
static void |
checkInstanceOrStatic(Object instance,
Method method)
Make sure that either we have an instance or if not, that the method is static
|
static void |
checkReturnType(Method method,
Class<?>... returnTypes) |
static XmlClass[] |
classesToXmlClasses(Class<?>[] classes) |
static void |
copyFile(File from,
File to)
Deprecated.
Unused
|
static File |
createTempFile(String content) |
static String |
defaultIfStringEmpty(String s,
String defaultValue) |
static String[] |
dependentGroupsForThisMethodForConfiguration(Method m,
IAnnotationFinder finder)
Deprecated.
Unused
|
static String[] |
dependentGroupsForThisMethodForTest(Method m,
IAnnotationFinder finder)
Deprecated.
Unused
|
static String |
detailedMethodName(ITestNGMethod method,
boolean fqn) |
static void |
dumpMap(Map<?,?> result)
Deprecated.
Unused
|
static void |
dumpMethods(List<ITestNGMethod> allMethods)
Deprecated.
Unused
|
static void |
error(String errorMessage) |
static String |
escapeHtml(String s) |
static String |
escapeUnicode(String s) |
static String[] |
groupsForThisMethodForConfiguration(Method m,
IAnnotationFinder finder)
Deprecated.
Unused
|
static String[] |
groupsForThisMethodForTest(Method m,
IAnnotationFinder finder)
Deprecated.
Unused
|
static boolean |
isStringBlank(String s) |
static boolean |
isStringEmpty(String s) |
static boolean |
isStringNotBlank(String s) |
static boolean |
isStringNotEmpty(String s) |
static <T> String |
join(List<T> objects,
String separator) |
static void |
log(String msg) |
static void |
log(String cls,
int level,
String msg)
Logs the the message to System.out if level is greater than
or equal to TestRunner.getVerbose().
|
static void |
logInvocation(String reason,
Method thisMethod,
Object[] parameters)
Deprecated.
Unused
|
static String |
longStackTrace(Throwable t,
boolean toHtml)
Helper that returns a short stack trace.
|
static BufferedWriter |
openWriter(String outputDir,
String fileNameParameter)
Open a BufferedWriter for the specified file.
|
static String[] |
parseMultiLine(String line)
Deprecated.
Unused
|
static String |
replaceSpecialCharacters(String fileNameParameter)
If the file name contains special characters like *,/,\ and so on,
exception will be thrown and report file will not be created.
Special characters are platform specific and they are not same for example on Windows and Macintosh. |
static String |
shortStackTrace(Throwable t,
boolean toHtml)
Helper that returns a long stack trace.
|
static String[] |
split(String string,
String sep)
Tokenize the string using the separator.
|
static String[] |
stackTrace(Throwable t,
boolean toHtml)
Deprecated.
- Please consider using :
|
static String[] |
stringToArray(String s)
Deprecated.
Unused
|
static String |
toString(Object obj)
Returns the string representation of the specified object, transparently
handling null references and arrays.
|
static String |
toString(Object object,
Class<?> objectClass) |
static void |
writeFile(String outputDir,
String fileName,
String sb)
Writes the content of the sb string to the file named filename in outDir.
|
static void |
writeResourceToFile(File file,
String resourceName,
Class<?> clasz) |
static void |
writeUtf8File(String outputDir,
String fileName,
String sb)
Writes the content of the sb string to the file named filename in outDir encoding the output as UTF-8.
|
static void |
writeUtf8File(String outputDir,
String fileName,
XMLStringBuffer xsb,
String prefix) |
public static final char CHAR_REPLACEMENT
public static final char UNICODE_REPLACEMENT
@Deprecated public static String[] stringToArray(String s)
s
- the string to split@Deprecated public static String[] parseMultiLine(String line)
public static void writeUtf8File(@Nullable String outputDir, String fileName, XMLStringBuffer xsb, String prefix)
public static void writeUtf8File(@Nullable String outputDir, String fileName, String sb)
outputDir
- the output directory (may not exist). If null then current directory is used.fileName
- the filenamesb
- the file contentpublic static void writeFile(@Nullable String outputDir, String fileName, String sb)
outputDir
- the output directory (may not exist). If null then current directory is used.fileName
- the filenamesb
- the file contentpublic static BufferedWriter openWriter(@Nullable String outputDir, String fileNameParameter) throws IOException
outputDir
- output directory. If null, then current directory is usedfileNameParameter
- file nameIOException
- if anything goes wrong while creating files.@Deprecated public static void dumpMap(Map<?,?> result)
@Deprecated public static void dumpMethods(List<ITestNGMethod> allMethods)
@Deprecated public static String[] dependentGroupsForThisMethodForTest(Method m, IAnnotationFinder finder)
@Deprecated public static String[] groupsForThisMethodForTest(Method m, IAnnotationFinder finder)
@Deprecated public static String[] groupsForThisMethodForConfiguration(Method m, IAnnotationFinder finder)
@Deprecated public static String[] dependentGroupsForThisMethodForConfiguration(Method m, IAnnotationFinder finder)
public static void log(String msg)
public static void log(String cls, int level, String msg)
"[cls] msg"
cls
- the class name to prefix the log message.level
- the logging level of the message.msg
- the message to log to System.out.public static void error(String errorMessage)
public static int calculateInvokedMethodCount(ITestNGMethod[] methods)
public static int calculateInvokedMethodCount(List<ITestNGMethod> methods)
public static String[] split(String string, String sep)
@Deprecated public static void logInvocation(String reason, Method thisMethod, Object[] parameters)
public static void writeResourceToFile(File file, String resourceName, Class<?> clasz) throws IOException
IOException
public static boolean isStringBlank(String s)
public static boolean isStringEmpty(String s)
public static boolean isStringNotBlank(String s)
public static boolean isStringNotEmpty(String s)
@Deprecated public static String[] stackTrace(Throwable t, boolean toHtml)
longStackTrace(Throwable, boolean)
- for getting full stack traceshortStackTrace(Throwable, boolean)
- for getting short stack tracepublic static String longStackTrace(Throwable t, boolean toHtml)
t
- - The Throwable
exceptiontoHtml
- - true
if the stacktrace should be translated to html as wellpublic static String shortStackTrace(Throwable t, boolean toHtml)
t
- - The Throwable
exceptiontoHtml
- - true
if the stacktrace should be translated to html as wellpublic static String detailedMethodName(ITestNGMethod method, boolean fqn)
public static String annotationFormFor(ITestNGMethod method)
method
- - An ITestNGMethod
object.public static String replaceSpecialCharacters(String fileNameParameter)
fileNameParameter
- file name that could contain special characters.@Deprecated public static void copyFile(File from, File to)
public static File createTempFile(String content)
public static void checkInstanceOrStatic(Object instance, Method method)
Copyright © 2018. All rights reserved.