Customizing Templates Tutorial

Applies to ReadyAPI 3.56, last modified on November 21, 2024

ReadyAPI supports a high degree of report customization. You can create as many report and subreport templates as you need. These reports can contain data from internal data sets and from any external source (for example, a database).

In this tutorial, you will learn how to use various template customization options available in ReadyAPI.

To learn how to customize your reports, create a simple custom report at the project level. To do that, first, you need to add a new project level report:

  1. From the main menu, select Project > Reporting.

  2. In the Reporting window, click to add a new report template.

  3. In the subsequent Add Report dialog, enter a report name – Properties and select a report type – COMMON. Click OK.

    Note: COMMON reports are available at all levels.
    ReadyAPI: The Add report dialog
  4. In the subsequent Choose Subreports dialog, select the PropertiesReport (TestProperties) subreport. Click OK.

    ReadyAPI: The Choose Subreports dialog
  5. The new template is now in the editor. Click OK to close the Reporting window.

    ReadyAPI: The new report template

    Click the image to enlarge it.

  6. In the Navigator panel, click the project name (SOAP Sample Project) and open the Custom Project Properties panel at the bottom.

    Custom Project Properties
  7. Click to add a custom property and enter a property name – My Property and a value – Property Value.

    Add a new custom property
  8. Click on the project editor toolbar to create a report.

    Project Editor Toolbar

    Click the image to enlarge it.

  9. In the subsequent Create Report dialog, select the Properties type. Click OK.

    ReadyAPI: Selecting a custom report type

    Click the image to enlarge it.

  10. ReadyAPI will create a report and display it:

    ReadyAPI: A custom report

    Click the image to enlarge it.

  11. The null Properties string is invalid. Select Project > Reporting from the top menu and switch to the Subreports tab to fix this.

  12. Find the PropertiesReport report in the table. To do this quickly, filter the reports by their type and scope:

    • Select COMMON from the Report type filter drop-down list.

    • Select GLOBAL from the Report scope filter drop-down list.

    • Click the report in the table.

    Filter reports by type and scope

    Click the image to enlarge it.

  13. In the editor under the table, find the code line that defines the contents of the invalid string.

    <textFieldExpression class="java.lang.String">$P{Type} + " Properties"</textFieldExpression>
    ReadyAPI: The Properties subreport in the editor

    Click the image to enlarge it.

  14. ReadyAPI passes Type as a parameter to the report. For now, add a hard-coded value. Switch to the Available Reports tab and select the Properties report template in the table. Insert the following text into the subreport element, which is a child element of the band element, and then click OK:

    JRXML

                <subreportParameter name="Type">
                    <subreportParameterExpression>"Test"</subreportParameterExpression>
                </subreportParameter>
    ReadyAPI: Adding a subreport parameter

    Click the image to enlarge it.

  15. Create a report again. Click and make sure the Properties type is selected in the Create Report dialog, click OK. Here is what it should look like:

    ReadyAPI: A custom report

    Click the image to enlarge it.

  16. Add a parameter that will define the report title.

    • Select Project > Reporting from the main menu, switch to the Available Reports tab and select the Properties report template in the table.

    • In the editor under the table, replace

      <textFieldExpression class="java.lang.String">$F{name} + " Report"</textFieldExpression>

      with
      <textFieldExpression class="java.lang.String">$P{ReportTitle}</textFieldExpression>

    ReadyAPI: Adding a custom report parameter

    Click the image to enlarge it.

  17. Switch to the Parameters tab. Click on the toolbar and enter the parameter name -  ReportTitle and the parameter value -   Default Title, then click OK.

    ReadyAPI: Adding a parameter on the parameters tab

    Click the image to enlarge it.

  18. Create a report again. Click and make sure the Properties type is selected in the Create Report dialog, click OK. Here is what it should look like:

    ReadyAPI: A custom report

    Click the image to enlarge it.

  19. ReadyAPI can override parameters you specified at any level. For COMMON reports, you can create parameters anywhere you need.

    For example, add a new parameter at the test case level:

    • Double-click a test case (for example, the Simple Login and Logout w. Properties Steps test case) in the Navigator panel.

      Open a test case
    • In the lowermost editor, switch to the Report Parameters tab.

    • Add a custom parameter as a property expansion. Click , enter the parameter name – ReportTitle and the value – ${=testCase.name}.

      ReadyAPI: Using a property expansion as the report parameter
  20. Create a test case level Property report. Click and make sure the Properties type is selected in the Create Report dialog, click OK. Here is what it should look like:

    ReadyAPI: A custom report

    Click the image to enlarge it.

  21. As you can see, a width issue has occurred. You can fix the issue either by editing the template or by adding configuration properties while creating a report.

    • Select Project > Reporting from the top menu.

    • On the Available Reports tab, open the Properties report template in the editor.
    • Add the following text to the template before the title element, and then click OK:

      JRXML

         <parameter name="ReportTitle" class="java.lang.String">
             <property name="interactive" value="true"/>
             <property name="label" value="Report Title"/>
             <parameterDescription>Sets the title in the Report</parameterDescription>
             <defaultValueExpression>"Default Title"</defaultValueExpression>
         </parameter>
      ReadyAPI: Adding a custom parameter in the editor

      Click the image to enlarge it.

    • A new option is now in the Create Report dialog. But, to use this feature, you need to remove the ReportTitle parameter you created on steps 17 and 19.

      ReadyAPI: A new option in the report creation
  22. Once you fix the issue, you can create a report one more time. Enter a new report name in the Report Title text box (for example, My Test Report) and click OK. Here is what the report should look like:

    ReadyAPI: A custom report

    Click the image to enlarge it.

To learn more about the available parameter types and options, see Configuration Parameter Reference.

See Also

Configuration Parameter Reference
About Property Expansions
Configuring Report Templates
Script Extensions

Highlight search results