Render Test Script Step Description Rich Text (XHTML) with Execution Variables


How to extract and render Test Script Step Description Rich Text (XHTML) with Execution Variables.

Thanks to Jeffrey Babylon for making time to write this article and sharing it with all of us.

Note: The following Test Script Steps below assume your RPE template already retrieves the Test Script or execution result where the steps live.

I use the following data sources to retrieve Test Case & Test Script Information:

Test Case Details Data Source (RQM Feed configured to inherit from my main data source for credentials, and using dynamic URI configuration where I script the URL to dynamically change for each test case)

rqm-feed-schema

Note: When using the following for URL configuration on the Data Source Configuration object you must be careful to account for any test case title which has an Ampersand in it because RPE will not translate it correctly. I use the following on Test Case Title before combining the pieces below: encodeURIComponent();

https://[host]:[port]/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources//testcase?fields=feed/entry/content/testcase[title='']/*

dsc-configuration

Test Script Details Data Source Pre-Execution: (RQM QM configured to inherit from my main data source for credentials, and using dynamic URI configuration where I use the href of the test script provided by feed/entry/content/testcase/testscript/href )

rqm-qm-schema

Test Script Details Data Source Post-Execution: (RQM QM configured to inherit from my main data source for credentials, and using dynamic URI configuration where I use the href of the execution result which has the associated “executed” Test Script Steps: feed/entry/content/executionworkitem/executionresult/href)

dsc-execution-result

 

For my RPE Template, I have 2 versions to account for Pre-Execution and Post-Execution because Post Execution you need to retrieve the steps from the execution result instead of the test case. I start with a single test plan and iterate over each test case collecting the following information:

For Pre-Execution:

  • Test Case ID/Name
  • Associated Test Script ID/Name (Assuming a one to one association)
  • Test Case Description
  • Test Case Pre-Requisites
  • Test Case Referenced Requirements
  • Test Case Attachments
  • Test Script Steps (Pre-Execution)
    • Step #
    • Step Description
    • Expected Results
    • Attachments/Links

For Post-Execution:

  • Test Case ID/Name (From RQM QM Data Source: WebId
  • Associated Test Script ID/Name (Assuming a one to one association)
  • Test Case Description
  • Test Case Pre-Requisites
  • Test Case Referenced Requirements
  • Test Case Attachments
  • Execution Details
    • Build Information
    • Run # / Execution Result ID
    • Environment
    • Test Script Steps (Post-Execution)
      • Step #
      • Step Description
      • Expected Results
      • Actual Results
      • Attachments/Links
      • Defects
      • Verdict
      • Tester/Start date/End date

For each Test Script you are iterating over in your template, the steps have a description element found in the following place:

For Pre-Execution Data Source:

It is under test script->Steps->Step

temp1

For Post-Execution Data Source:

It is under executionresult->stepResults->StepResult

temp2

If your Test Scripts contain Execution variables like the following:

test-script-exec

The Rich Text provided by _value for the description will contain the following xhtml if you select the checkbox for xhtml input in the script editor for the javascript

Set  CM_username_3891 to the value of the environment variable {{CM_username_3891}} which is the value of the patientid extension in the Contract resource created above.

 

script-2

This XHTML is not renderable by RPE so it must be changed in the javascript.  I chose to simply chose to turn it into a span statement in the following way. (Note: I am using separate variables for each xhtml change to emphasize the changes here) The use of split followed by a join produces a global find and replace effect.

var xhtmlChg0 = _value.split("button type=\"button\" ").join("span ");
var xhtmlChg1 = xhtmlChg0.split("disabled=\"true\"").join("");
var xhtmlChg2 = xhtmlChg1.split("class=\"executionVariable\"").join("");
var xhtmlChg3 = xhtmlChg2.split("name=\"ExecVariable\"").join("");
var xhtmlChg4 = xhtmlChg3.split("background:#EEFFFF").join("background-color:#EEF4F4");
var xhtmlChg5 = xhtmlChg4.split("font-size:10pt").join("font-size:12pt");
var xhtmlChg6 = xhtmlChg5.split("/button").join("/span");
var xhtmlChg7 = xhtmlChg6.split("▶").join(" ►");
var xhtmlChg8 = xhtmlChg7.split("").join(" ");

Assign xhtmlChg8 to your variable for use.

This same set of changes can be applied to your “executed” Test Script Step descriptions to produce the following output provided the text box where you are using the value has xhtml output checked

script

Pre-Execution Rendering:

pre-exec-rendering

Post-Execution Rendering:

post-exec-rendering

Advertisements

Author: Kumaraswamy M

Kumar is an architect for Rational Publishing Engine. He has been with the product for more than 4 years and has been involved in many releases of RPE. His expertise are in Web application development and API design. He loves going on a long ride on bike and conquering peaks during weekend treks.

2 thoughts on “Render Test Script Step Description Rich Text (XHTML) with Execution Variables”

  1. Thanks Kumar, just a minor comment. I think the wiki lost the following when it converted the document.
    var xhtmlChg7 = xhtmlChg6.split(“▶”).join(” ►”);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s