IBM Support

Iterating programmatically through all datapool rows in Rational Functional Tester

Question & Answer


Question

How do I iterate through all datapool rows programmatically in an IBM Rational Functional Tester script?

Cause

The script launch wizard includes an option "iterate until done" for the Datapool Iteration Count.

This technote explains how to programmatically emulate the behavior of "iterate until done", eliminating the need to manually set the Datapool Iteration Count in the script launch wizard.

Answer

To programmatically implement "iterate until done":

  • Create a while loop which calls the dpDone() API to check whether all rows have been iterated.
  • Use the dpNext() API to advance to the next datapool row.
  • Optional: Print the current datapool row to the log using the logInfo() API.
  • Execute the script with "Datapool Iteration Count" set to 1, and note that it automatically iterates through all rows in the datapool.

An example utilizing these three APIs is shown below. Also see the attachment iterateUntilDone_example.rftjdtr. Save this file to your desktop, then use "File > Import > Functional Test > Functional Test Project Items" to import the script iterateUntilDone_example into your project.

iterateUntilDone_example.rftjdtr



public void testMain(Object[] args)
{

// Instantiate a counter to track the current datapool row for logging purposes
int currentDatapoolRow = 0;

// Iterate until all rows in the datapool have been used
while (!dpDone()) {

// Print the current datapool row number to the playback log
logInfo("Starting datapool row " + currentDatapoolRow);

// Print the current datapool row & current value of Variable1 to the console (for debug purposes)
System.out.println("INFO: For row " + currentDatapoolRow + " the value of Variable1 is: " + dpString("Variable1"));

// TODO Insert code here

// Increment currentDatapoolRow
currentDatapoolRow++;

// Advance to next datapool row
dpNext();
}
}


 DISCLAIMER:

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

[{"Product":{"code":"SSJMXE","label":"IBM Rational Functional Tester"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Datapool","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.0;7.0.0.1;7.0.0.2;7.0.1;7.0.1.1;7.0.1.2;7.0.1.3;8.0;8.0.0.1;8.0.0.2;8.0.0.3;8.1;8.1.0.1;8.1.0.2;8.1.0.3;8.1.1;8.1.1.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21440826