You can extend the default reports by using report scripts that are available for test suite and test case reports. ReadyAPI runs report scripts each time it creates a report. To work with the script, use the script editor on the Report tab of the corresponding editor:
![]() |
Report scripts can use the following objects:
log
– an object for interacting with the log.report
– an object that holds all data used to populate the report. Its members allows you to add or adjust data and subreport data the report engine uses to fill the report template.params
– an object that contains all defined report parameters and their values.Also, scripts can access an object that represents the current test item (
testSuite
ortestCase
).
Mostly, when working with your report data, you will use the report
and params
objects.
Below is information on how to perform some useful tasks by using the report script.
The params
object allows you to modify parameters declared in a report template or on the Report Parameter tab.
To access a parameter, specify its name after the period:
For example, you define an integer parameter in a report template:
Now, you can change it from script by using the following expression:
Each default report includes some metrics produced by the MetricsReport
subreport. This subreport shows the execution-related metrics. You can include extra metrics in this report by using the report.addMetric()
method. For example, the following code snippet adds the version of the operating system:
By default, new metrics are added to the Base Metrics section. You can also add them to a custom section. The code snippet below shows how to list all the system properties under the System Properties category.
You use subreports to create a report within the main report. Each subreport uses a template and provides a data source to include the needed data in the parent report.
Using the report
object you can access an existing subreport as well as create new ones. The example below shows how to create a subreport containing system properties.
Adding a Subreport to a Report Template
A system property consists of two parts: the name and value. To pass it to a subreport, you can use a helper class that has two variables: name
and value
. ReadyAPI passes this class to the subreport template for each data record. To declare the class, open the Report script tab and enter the following code:
From the main menu, select Project > Reporting.
In the Reporting dialog, switch to the Subreports tab.
Click
to create a new subreport template.
Specify the properties of the new template:
Enter the following text as the new template content:
The
field
elements represent a piece of data obtained from a data source. Thename
attribute of these fields must coincide with variable names declared in a class representing the data record. In this example, two fields,name
andvalue
, match variables declared in theNVPair
class on the previous step.To insert field values, use the
$F{<field name>}
expression. In the example above, the$F{name}
expression inserts the value of thename
variable, and$F{value}
inserts the value of the variable.
To add a subreport to a report, use the subreport
element of the report template. To do this, perform the following steps:
Switch to the Available Reports tab of the Reporting dialog.
Select the template to which you want to add a template. For example, the standard
Test Case Report
.Insert the following text to a
band
element, which is a child element of thedetail
element:Important
Make sure the value of the
height
attribute of theband
element is greater than the value of theheight
attribute of the subreport footer element. In this example, it must be greater than 418 (the sum of they
andheight
values).The following elements specify subreport details:
The
dataSourceExpression
element specifies the data source that will feed a subreport with data.The
subreportExpression
element specifies the used subreport template.
To pass a data source to the subreport, we use the
SystemProperties
parameter. To declare the parameter in the template, specify a newparameter
element at the beginning of the template:
To grab data to show and produce the needed data source, create a custom SystemPropertiesSubReport
class.
Add the following code at the beginning of the Report script
To build a data source and pass it to the report template, use the following code:
To test the created subreport, click and select the template to which you are adding the subreport:

You can make this subreport optional:
Include the following
parameter
element at the end of parameters element in the main template:Add the following conditional to the
subreport
element:
Now when you select the created template in the Create Report dialog, you can select whether to include this subreport in the report:
