Class Report
- Namespace
- Ranorex
- Assembly
- Ranorex.Core.dll
The Ranorex reporting service.
Used to log messages to a number of configured loggers.
public class Report
- Inheritance
-
Report
- Inherited Members
Properties
CustomCategoryStyles
Allows setting of custom formatting CSS styles per category. These styles override ReportLevel styles if set.
public static Dictionary<string, string> CustomCategoryStyles { get; }
Property Value
DefaultCategory
Gets or sets the default report category to use if not explicitly specified when reporting messages.
public static string DefaultCategory { get; set; }
Property Value
- string
The default category name.
MinimumReportLevel
Gets or sets the current report level that is the minimum ReportLevel message need to have to be included in the report.
public static ReportLevel MinimumReportLevel { get; set; }
Property Value
- ReportLevel
The minimum report level that log entries need to have to be included in the report.
Remarks
The default level is Info.
Methods
AttachLogger(IReportLogger)
Attaches a custom logger to the reporting environment.
public static void AttachLogger(IReportLogger logger)
Parameters
loggerIReportLoggerThe logger.
Copy(ReportEnvironment, string)
Copies a XML or zipped XML report file and all the external files referenced by the report file to a file. This method automatically handles copying from and to zipped and unzipped report files.
public static void Copy(ReportEnvironment reportEnvironment, string destinationReportFileName)
Parameters
reportEnvironmentReportEnvironmentCurrent report environment.
destinationReportFileNamestringFull path to copy the report file to.
Remarks
Make sure the report is saved first to copy all files. Only currently existing files are copied.
Copy(string, string)
Copies a XML or zipped XML report file and all the external files referenced by the report file to a file. This method automatically handles copying from and to zipped and unzipped report files.
public static void Copy(string sourceLog, string destinationReportFileName)
Parameters
sourceLogstringFull path to the source report file.
destinationReportFileNamestringFull path to copy the report file to.
Remarks
Make sure the report is saved first to copy all files. Only currently existing files are copied.
Debug(string)
Logs a debug-level message, using the default category.
public static void Debug(string message)
Parameters
messagestringThe message text.
Debug(string, string)
Logs a debug-level message.
public static void Debug(string category, string message)
Parameters
DetachLogger(IReportLogger)
Detaches a custom logger from the reporting environment.
public static void DetachLogger(IReportLogger logger)
Parameters
loggerIReportLoggerThe logger.
End()
Ends reporting. It is not required to explicitly call this method before shutdown.
public static void End()
Error(string)
Logs an error-level message, using the default category.
public static void Error(string message)
Parameters
messagestringThe message text.
Error(string, string)
Logs an error-level message.
public static void Error(string category, string message)
Parameters
Failure(string)
Logs a logical failure (e.g. test step failure) message, using the default category.
public static void Failure(string message)
Parameters
messagestringThe message text.
Remarks
Calling this method marks the current test container as failed, but does not stop execution of the current module or test container. If you want the execution of the current module to stop immediately, call Fail(string) instead.
Failure(string, string)
Logs a logical failure (e.g. test step failure) message.
public static void Failure(string category, string message)
Parameters
Remarks
Calling this method marks the current test container as failed, but does not stop execution of the current module or test container. If you want the execution of the current module to stop immediately, call Fail(string) instead.
~Report()
Finalizer for automatic logger shutdown.
protected ~Report()
HasReportDataFileExtension(string)
Determines if a file name has the Ranorex Stub View report file extension.
public static bool HasReportDataFileExtension(string reportFileName)
Parameters
reportFileNamestringThe file name to check.
Returns
- bool
Trueif the file has the ".rxlog.data" extension.
HasReportFileExtension(string)
Determines if a file name has the Ranorex Xml report file extension.
public static bool HasReportFileExtension(string reportFileName)
Parameters
reportFileNamestringThe file name to check.
Returns
- bool
Trueif the file has the ".rxlog" extension.
HasZipReportFileExtension(string)
Determines if a file name has the Ranorex Zip report file extension.
public static bool HasZipReportFileExtension(string reportFileName)
Parameters
reportFileNamestringThe file name to check.
Returns
- bool
Trueif the file has the ".rxzlog" extension.
Info(string)
Logs an info-level message, using the default category.
public static void Info(string message)
Parameters
messagestringThe message text.
Info(string, string)
Logs an info-level message.
public static void Info(string category, string message)
Parameters
IsReportFile(string)
Determines if a file is a valid Ranorex report file.
public static bool IsReportFile(string reportFileName)
Parameters
reportFileNamestringThe file name to check.
Returns
- bool
Trueif the file is a valid Ranorex report file.
IsReportFile(string, string)
Determines if a file is a valid Ranorex report file.
public static bool IsReportFile(string reportFileName, string fileFilter)
Parameters
reportFileNamestringThe file name to check.
fileFilterstringA list of known file extensions that are not report files.
Returns
- bool
Trueif the file is a valid Ranorex report file.
Link(ReportLevel, string, string, string, params IReportMetadata[])
Adds the specified link to the report. If the link is a relative file path or points to a file within the report directory, the linked file will also be included in zipped or copied versions of the report.
public static void Link(ReportLevel level, string category, string message, string link, params IReportMetadata[] metaData)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messagestringAn optional message to log to the report.
linkstringThe link to add to the report.
metaDataIReportMetadata[]Advanced reference information for use in the report. Used by Ranorex internally.
Exceptions
- ArgumentNullException
If
categoryorlinkarenull.
Link(string)
Adds the specified link to the report. If the link is a relative file path or points to a file within the report directory, the linked file will also be included in zipped or copied versions of the report.
public static void Link(string link)
Parameters
linkstringThe link to add to the report.
Exceptions
- ArgumentNullException
If
linkisnull.
Link(string, string)
Adds the specified link to the report. If the link is a relative file path or points to a file within the report directory, the linked file will also be included in zipped or copied versions of the report.
public static void Link(string message, string link)
Parameters
Exceptions
- ArgumentNullException
If
linkisnull.
Log(ReportLevel, string)
Logs a message using the DefaultCategory.
public static void Log(ReportLevel level, string message)
Parameters
levelReportLevelThe reporting level of the message.
messagestringThe message text itself.
Log(ReportLevel, string, string)
Logs a message.
public static void Log(ReportLevel level, string category, string message)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messagestringThe message text itself.
Log(ReportLevel, string, string, params IReportMetadata[])
Logs a message.
public static void Log(ReportLevel level, string category, string message, params IReportMetadata[] metaData)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messagestringThe message text itself.
metaDataIReportMetadata[]Advanced reference information for use in the report. Used by Ranorex internally.
LogData(ReportLevel, string, object)
Logs a data message.
public static void LogData(ReportLevel level, string category, object data)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
dataobjectThe data object to log.
Remarks
Note that this is not support by all loggers, nor are all data types supported.
LogData(ReportLevel, string, string, object)
Logs a data message.
public static void LogData(ReportLevel level, string category, string message, object data)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messagestringAn optional message for the data.
dataobjectThe data object to log.
Remarks
Note that this is not support by all loggers, nor are all data types supported.
LogData(ReportLevel, string, string, object, params IReportMetadata[])
Logs a data message.
public static void LogData(ReportLevel level, string category, string message, object data, params IReportMetadata[] metaData)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messagestringAn optional message for the data.
dataobjectThe data object to log.
metaDataIReportMetadata[]Advanced reference information for use in the report. Used by Ranorex internally.
Remarks
Note that this is not support by all loggers, nor are all data types supported.
LogHtml(ReportLevel, string)
Logs a message using the DefaultCategory. The message can contain XHTML markup.
public static void LogHtml(ReportLevel level, string messageHtml)
Parameters
levelReportLevelThe reporting level of the message.
messageHtmlstringThe message text itself.
LogHtml(ReportLevel, string, string)
Logs a message. The message must contain valid XHTML markup.
public static void LogHtml(ReportLevel level, string category, string messageHtml)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messageHtmlstringThe message text itself.
LogHtml(ReportLevel, string, string, params IReportMetadata[])
Logs a message. The message must contain valid XHTML markup.
public static void LogHtml(ReportLevel level, string category, string messageHtml, params IReportMetadata[] metaData)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messageHtmlstringThe message text itself.
metaDataIReportMetadata[]Advanced reference information for use in the report. Used by Ranorex internally.
ProcessSummary(Element)
Logs a message containing a short process summary.
public static void ProcessSummary(Element element)
Parameters
elementElementAn element which belongs to the process to gather information from.
Remarks
The process summary contains information about the process resource usage.
ProcessSummary(RepoItemInfo)
Logs a message containing a short process summary.
public static void ProcessSummary(RepoItemInfo repoItemInfo)
Parameters
repoItemInfoRepoItemInfoAn repository item representing an element which belongs to the process to gather information from.
Remarks
The process summary contains information about the process resource usage.
ProcessSummary(Process)
Logs a message containing a short process summary.
public static void ProcessSummary(Process p)
Parameters
pProcessThe process to gather information from.
Remarks
The process summary contains information about the process resource usage.
ProcessSummary(int)
Logs a message containing a short process summary.
public static void ProcessSummary(int pid)
Parameters
pidintThe process id of the process to gather information from.
Remarks
The process summary contains information about the process resource usage.
ProcessSummary(string)
Logs a message containing a short process summary.
public static void ProcessSummary(string imageName)
Parameters
imageNamestringThe name of the process image/executable to gather information from.
Remarks
The process summary contains information about the process resource usage.
Screenshot()
Logs a message containing a screenshot of the whole desktop.
public static void Screenshot()
Remarks
This is not supported by the console logger.
Screenshot(Element)
Logs a message containing a screenshot of a specified element.
public static void Screenshot(Element target)
Parameters
targetElementThe element to make the screenshot from.
Remarks
Screenshots will not show up in the console logger.
Screenshot(Element, bool)
Logs a message containing a screenshot of a specified element.
public static void Screenshot(Element target, bool highlightWithinSurroundingArea)
Parameters
targetElementThe element to make the screenshot from.
highlightWithinSurroundingAreaboolIf set to
truethe screenshot will not only contain the element, but also its surrounding area and will highlight the element within it.
Remarks
Screenshots will not show up in the console logger.
Screenshot(ReportLevel, string, string, Element, bool, params IReportMetadata[])
Logs a message containing a screenshot of a specified element.
public static void Screenshot(ReportLevel level, string category, string message, Element target, bool highlightWithinSurroundingArea, params IReportMetadata[] metaData)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messagestringAn optional message for the screenshot.
targetElementThe element to make the screenshot from.
highlightWithinSurroundingAreaboolIf set to
truethe screenshot will not only contain the element, but also its surrounding area and will highlight the element within it.metaDataIReportMetadata[]Advanced reference information for use in the report. Used by Ranorex internally.
Remarks
Screenshots will not show up in the console logger.
Screenshot(string, Element)
Logs a message containing a screenshot of a specified element.
public static void Screenshot(string message, Element target)
Parameters
messagestringAn optional message for the screenshot.
targetElementThe element to make the screenshot from.
Remarks
Screenshots will not show up in the console logger.
Screenshot(string, Element, bool)
Logs a message containing a screenshot of a specified element.
public static void Screenshot(string message, Element target, bool highlightWithinSurroundingArea)
Parameters
messagestringAn optional message for the screenshot.
targetElementThe element to make the screenshot from.
highlightWithinSurroundingAreaboolIf set to
truethe screenshot will not only contain the element, but also its surrounding area and will highlight the element within it.
Remarks
Screenshots will not show up in the console logger.
Setup(ReportLevel, string, bool)
Sets up the reporting environment compatible with Ranorex version 2.X.
public static void Setup(ReportLevel minLevel, string xmlReportFileName, bool logToConsole)
Parameters
minLevelReportLevelThe minimum ReportLevel for messages that are to be written to the report.
xmlReportFileNamestringName of the XML report file, or null if XML logging should be disabled.
logToConsoleboolif set to
true, logging to console is enabled.
Setup(ReportLevel, string, bool, bool)
Sets up the reporting environment compatible with Ranorex version 2.X.
public static void Setup(ReportLevel minLevel, string xmlReportFileName, bool logToConsole, bool appendExisting)
Parameters
minLevelReportLevelThe minimum ReportLevel for messages that are to be written to the report.
xmlReportFileNamestringName of the XML report file, or null if XML logging should be disabled.
logToConsoleboolif set to
true, logging to console is enabled.appendExistingboolif set to
true, append to existing XML file instead of overwriting it.
SetupDefault()
Sets up the reporting environment with Info, XML logging and console logging enabled.
public static void SetupDefault()
Snapshot(Element)
Creates and stores a snapshot of the specified target element
and adds a link to the snapshot to the report.
public static void Snapshot(Element target)
Parameters
targetElementThe target element to create the snapshot of.
Exceptions
- ArgumentNullException
If
targetisnull.
Snapshot(ReportLevel, string, string, Element, params IReportMetadata[])
Creates and stores a snapshot of the specified target element
and adds a link to the snapshot to the report.
public static void Snapshot(ReportLevel level, string category, string message, Element target, params IReportMetadata[] metaData)
Parameters
levelReportLevelThe reporting level of the message.
categorystringThe category name.
messagestringAn optional message to log to the report.
targetElementThe target element to create the snapshot of.
metaDataIReportMetadata[]Advanced reference information for use in the report. Used by Ranorex internally.
Exceptions
- ArgumentNullException
If
targetisnull.
Snapshot(string, Element)
Creates and stores a snapshot of the specified target element
and adds a link to the snapshot to the report.
public static void Snapshot(string message, Element target)
Parameters
messagestringAn optional message to log to the report.
targetElementThe target element to create the snapshot of.
Exceptions
- ArgumentNullException
If
targetisnull.
Start()
Starts reporting with the previously configured settings.
public static void Start()
Remarks
To restart reporting, End() needs to be called first.
Success(string)
Logs a logical success (e.g. test step success) message, using the default category.
public static void Success(string message)
Parameters
messagestringThe message text.
Success(string, string)
Logs a logical success (e.g. test step success) message.
public static void Success(string category, string message)
Parameters
SystemSummary()
Logs a message containing a short system the summary.
public static void SystemSummary()
Remarks
The system summary contains information about the host, OS, locale, memory and screens.
Unzip(string, string)
Unzips a zipped XML report file (with the extension ".rxzlog") and all the external files references.
public static string Unzip(string zipReportFileName, string targetDirectory)
Parameters
zipReportFileNamestringFull file path of the zipped ".rxzlog" file.
targetDirectorystringThe directory to save extracted XML report file in.
Returns
- string
The full file path of the extracted XML report file.
Warn(string)
Logs a warning-level message, using the default category.
public static void Warn(string message)
Parameters
messagestringThe message text.
Warn(string, string)
Logs a warning-level message.
public static void Warn(string category, string message)
Parameters
Zip(ReportEnvironment, string, string)
Zips the XML report file and all the external files referenced by the report file to a zip file with the extension ".rxzlog".
public static void Zip(ReportEnvironment reportEnvironment, string targetDirectory, string zipReportFileName)
Parameters
reportEnvironmentReportEnvironmentActive report environment.
targetDirectorystringDirectory to save zipped XML report file in. If
nullor empty, CurrentDirectory is used.zipReportFileNamestringName of the zipped report file. The ".rxzlog" extension is added by default.
Zip(string, string, string)
Zips the XML report file and all the external files referenced by the report file to a zip file with the extension ".rxzlog".
public static void Zip(string sourceLog, string targetDirectory, string zipReportFileName)
Parameters
sourceLogstringFull path to the source report file.
targetDirectorystringDirectory to save zipped XML report file in. If
nullor empty, CurrentDirectory is used.zipReportFileNamestringName of the zipped report file. The ".rxzlog" extension is added by default.