0

Is it possible to use a single datapool for all my scripts? Each of the script already has an existing datapool and what I want is to not use that and instead use a master datapool. The master datapool should contain all the columns of each script.

I should also have a main script that functions as a caller to all my scripts, so the code should only be in the main script, the scripts to be called should not be modified.

For example: I have a login script which has a username and password, then an add_employee script which contains the first name and last name.

  • The master datapool contains the username, password, first name and last name columns.
  • The main script contains only the code for using a specified (master) datapool for all its call scripts, and the scripts to be called.

I've tried reading the code from the link below but the code needs to be inserted in every (sub)script, I think. What I need is a code in the main script that will affect all scripts to be called. Rational Functional Tester - How can I get scripts called from a parent script to use the parent's data pool?

Community
  • 1
  • 1

2 Answers2

0

Not quite sure how to solve your datapool problem, but there is a way to write code that affects all your scripts—using a super helper class.

In Functional Tester, all scripts have a script helper superclass. All script helper classes are subclasses of RationalTestScript. With a super helper class, the scripts are subclasses of the super helper class and the super helper class inherits from RationalTestScript.

So all you need to do is to create a class which extends RationalTestScript and use it as super helper class. The super helper class of a test script is set in the properties of the test script. You can set the default super helper class in the project settings.

More about super helper classes: http://www.ibm.com/developerworks/rational/library/1093.html.

Roland
  • 1,220
  • 1
  • 14
  • 29
0

You can supply datapool values of caller script to the callee as script arguments. Callee should override dpString method to be able to read its datapool values from script arguments in case it is called from another script.

This looks like a good blog topic by the way!

Tried to summarize the solution, hope it gives you an idea:

You need to

define a helper super class:

public abstract class SingleDPSupport extends RationalTestScript

with a field to identify that one script is called from another:

private static bool isCalledFromAnother = false;

Provide another callScript method:

protected void callMyScript(RationalTestScript script,  Object[] args)
{
    isCalledFromAnother = true;
    args = appendDp(args);//this method should append datapool values to args array with a special prefix such as "_dp_"
    callScript(script, args);
    isCalledFromAnother = false;
}

Override dpString to read these special arguments:

public String dpString(String variableName) {
    if (isCalledFromAnother)
        return findDpStringFromArgs(getScriptArgs(), DP_ARG_NAME_START+variableName, null);

    return super.dpString(variableName);
}
Cagin Uludamar
  • 372
  • 1
  • 3
  • 16