Customizing Templates Tutorial

ReadyAPI supports a high degree of report customization. You can create as many reports 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 add.png 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
  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 add.png to add a custom property and enter a property name – My Property and a value – Property Value.

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

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

    ReadyAPI: Selecting a custom report type
  10. ReadyAPI will create a report and display it:

    ReadyAPI: A custom report
  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
  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
  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:

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

    customizing-pdf-2.png
  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
  17. Switch to the Parameters tab. Click add.png 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
  18. Create a report again. Click Report and make sure the Properties type is selected in the Create Report dialog, click OK. Here is what it should look like:

    customizing-pdf-3.png
  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 add.png , 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 Report and make sure the Properties type is selected in the Create Report dialog, click OK. Here is what it should look like:

    customizing-pdf-4.png
  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:

      ReadyAPI: Adding a custom parameter in the editor
    • 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:

    customizing-pdf-5.png

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

See Also

Publication date: