Complex report customization
In this chapter, you’ll find instructions on how to perform a range of more complex report customizations. Since they require coding skills, you should be familiar with code modules in Ranorex Studio.
Further reading
Download the sample solution
The examples in this chapter are based on a sample solution that you can download from the link below.
Sample solution
Time: 30 minutes
Install the sample solution:
Unzip to any folder on your computer.
Start Ranorex Studio and open the solution file RxDatabase.rxsln
Hint
The standard report classes
The easiest way to create a report message in code is using one of the six different standard report classes.
Standard report classes
Ranorex Studio has six standard report classes, as shown below. These classes correspond to the standard report levels.
Ranorex.Report.Debug(“Debug message”);
Ranorex.Report.Info(“Information message”);
Ranorex.Report.Warn(“Warning message”);
Ranorex.Report.Error(“Error message”);
Ranorex.Report.Success(“Success message”);
Ranorex.Report.Failure(“Failure message”);
Report messages from standard report classes
Hint
Report with user code actions
In addition to using code modules, you can also create report messages in recording modules with user code actions.
Further reading
Ranorex Studio fundamentals > Actions > ⇢ User code actions.
ReportInformation()
and open it.Customize the default report category
By default, the category of custom report messages is User. You can change this to a different value, either on a per-message basis or for all messages until you change it back.
Per message
Defining a temporary custom report category
Result:
Change default category
Defining a permanent custom report category
Result:
Define custom report levels
You can define report levels with a custom name and value.
Result:
Format custom report levels
Set threshold report level with custom report levels
In this example, you’ll set the threshold report level for messages using a custom report level.
Result:
Override current report level
You can override the current report level with the special report level Always.
Overriding the current report level
Result:
Report screenshots
Further reading
Report a system summary
Add customized data
You can collect customized data during a test run and write it to the raw data file (.rxlog.data) that’s used to generate the final report.
Add custom data to raw data file
Customized data collection is triggered by a user code action with a method that tracks customized data.
The activity stack is where all activities during a test run are collected by means of a stack data structure.
The activity stack method CustomProperties adds a reported activity to the activity stack. It is defined by two strings, name (e.g. myName) and value (e.g. myValue).
Result:
- The result is a custom data field pair in the corresponding data file
- If you want to apply the test data outside of Ranorex Studio report generation, you can parse the XML file as needed.
- To include the custom data in a Ranorex Studio report, please refer to the next section.
Include custom data in report
Further reading
Add the code in the picture below to the file.