White Papers
Abstract
The IBM® Rational® Test RealTime™ 7.5 release has a new feature. In this release the Target Deployment Port developers can customize the report files header of Component Testing and System Testing. Now you can add company and project specific information into the header of the report, as soon as the report is built. This document describes the best way of using this feature.
Content
Scripts from the Target Deployment Port (TDP) perform the customization of the reports. The reason for choosing the TDP for storing the customization scripts is, that software development projects typically have TDPs that are specific to the project.
The basic steps are:
- Duplicate a Target Deployment Port.
- Enable the customization script in the TDP.
- Add the customization script to the TDP.
- Declare the script as the report customization script.
- Write the customization script.
- Test the customization script.
Below are the steps in detail. We assume that you are familiar with:
- The Test RealTime user interface,
- how to build tests and view the test reports,
- the Perl programming language, the Practical Extraction and Report Language.
1. Duplicating a Target Deployment Port
The first step is to duplicate an existing Target Deployment Port. In this TDP you will add a script to add the name of the computer and user who is running the test.
- In the Target Deployment Port directory, locate the TDP that you currently use. Typically the locations are
C:\Program Files\Rational\TestRealTime\targets\xml on Microsoft® Windows® or /opt/rationa/releases/TestRealTime.7.5/targets/xml on Linux® and Unix®.
- Copy this TDP into a new name. For example copy the cvisual8.xdp and name the copy project8.xdp.
- Now open this copied TDP in the TDP editor.
- Modify the name of the TDP.
Select the top node of the TDP tree and press the F2 key.
Alternatively right click and click rename.
Choose a unique name for the TDP and then save the TDP. See figure 1.

figure 1
2. Enabling the customization script in the TDP
You need two steps to add the report customization script to the TDP. The first step is to add the script to the TDP. The second step is to declare this script as the one to use for customizing the report.
- Select the Basic Settings > For All node.
- Click the Add button.
- Enter the name of the new key as REPORTHEADER when prompted.
- Click on the value field and change it to the name of the script file.
Example:
2a. Adding the customization script to the TDP
To add a script to the TDP, right click on the Build Settings node; then click
Add Child > Ascii File.

figure 2
This will create the new node NewAsciiFile.txt. Rename this file immediately to something more meaningful such as report.pl. Note the .pl extension, because the customization script will be in the Perl language. Therefore you should now have a new node in the TDP with no content like the following snapshot.
figure 3
You will see the customization script in the section Enter text here:.
When you save and generate the TDP, it creates an empty file report.pl in the cmd directory. Typically this directory is:
C:\Program Files\Rational\TestRealTime\targets\project8\cmd\report.pl .
2b. Declaring the script as the report customization script
Now you have a new script in the TDP. The second step is to tell Test RealTime to run this script to customize the report. For that you create a new key REPORTHEADER in the Basic Settings > For All section with the name of the script as its value.
To create a new key:

figure 4
3. Writing the customization script
Go back to the customization script by selecting the Build Settings > report.pl node and put the following code in the Enter text here: section :
sub reportHeader { my $headerFile = shift; my $inEclipse = shift; print "\nThe custom report script has been executed\n\n"; } 1; |
This code defines the Perl subroutine reportHeader and extracts the two parameters into local variables. It then prints out a message to show that it has been executed.
To save and generate this TDP, click File > Save & Generate.
4. Testing the customization script
Ti verify that Test RealTime calls he customization script, you need to do three things.
- Load a Component Testing project into the Test RealTime user interface,
- Select your new TDP,
- Then rebuild your test.
A good project to use is an example delivered with Test RealTime, in the examples/TDP/adddirectory.
- Load the add.rtp into the Test RealTime user interface.
- Now add the newly created TDP into the list of configurations available through
Project > Configurations.... - In the Configurations dialog box click the New... button.
- In the New Configuration dialog box, select the TDP you have just created from the Select a Target Deployment Port drop down list.
figure 5
- Click on OK to close this dialog box.
- Click Activate to select your new configuration
- Then click on Close to close this dialog box.
figure 6
You can now select the test node in the Project Browser and then rebuild this node. You see in the Build output window the message from the print statement in the script.
figure 7
If you do not see the message verify that REPORTHEADER contains the correct name of the script. You can see that the full path in the output window. Also verify that the script is correctly written.
Enhancing the customization script
So now that the script is called, you need to enhance it to add the information you want to appear in the test report header. As you can see the customization script is a single Perl function called "reportHeader". It is passed a file name as a parameter and a flag to indicate if you are executing under Eclipse or not. The file name passed as a parameter is a file that contains the current header information. The contents of this file look like this:
|
You may have more lines if you enabled Code Coverage on your project.
As you can see, the file consists of keys and values separated by the equals, (=), sign. Therefore if you want to add extra lines to the header, you just need to print to the end of this file a key and a value. The following script adds a key called Custom report with a value
Has been run!!:
|
The above script will produce the following report header:

figure 8
As you can see the last line in the header is your customization.
Advanced Customization
You can enhance the script further to put the customization options in their own header block and to access environment variables like this:
|
This will produce the following header in the test report:

figure 9
The syntax #Name introduces a new section in the test report. You can have as many sections as you wish.The value for the key an be any value that you can access from Perl and can convert to a string.
Best practices
Always put a new customization script in a new TDP. This placement ensures, that only the software projects, that use this new TDP, have the customization applied to the test reports. Putting the customization in a different section in the test report will ensure that this information is easily visible.
Original Publication Date
17 October 2008
Product Synonym
testrt
rtrt
Was this topic helpful?
Document Information
More support for:
Rational Test RealTime
Software version:
7.5
Operating system(s):
AIX, HP-UX, Linux, Solaris, Windows
Document number:
321031
Modified date:
17 June 2018
UID
swg27013874