Example: Linking substitutions to references with rules

You can create data correlation rules to link substitutions to references.

About this task

If you are familiar with the application under test and know the exact location of the reference in the response data, write a Create a reference rule that uses a regular expression to locate the reference data, and then insert a Create a substitution rule as a child of the Create a reference rule.

Procedure

  1. Open a data correlation rule set in the rules editor.
    A new rule set contains one empty rule pass.
  2. Create a Create a reference rule. See Creating a reference using data correlation rules to learn more about creating a Create a reference rule.
  3. Right-click the Create a reference rule, and then click Insert Item > Link with substitutions.
  4. Right-click the Link with substitutions rule, and then click Insert Item > Create a substitution. To use the value of the reference that is extracted by the parent rule, type %refname% for the Regular expression, where refname is the name of the reference that is created by the parent rule. See Creating a substitution with data correlation rules to learn more about creating a Create substitution rule.
    A Create a substitution rule is inserted as a child of the Link with substitutions rule.

Results

When you recorrelate test data with this rule set, the references and substitutions that you defined are created and linked.

Example

Assume that a response in your test data contains an ID that is present in URIs and in POST data throughout the test. For example, the response includes ...<NeededID=ID123 docHelpName=rules>.... Assume that a URI in the test is http://host:port/RPTHelpID123/index.jsp?topic=datacorrelation.html and the POST data includes ...nameID123=ID123.... Because you know the exact location of the ID in the response, you can write a rule that creates a reference for the ID. Specify the Reference name as ID. Then, add rules for two substitutions as children of the reference rule. Add one substitution with a URI attribute and one with a data attribute. Specify %id% in Regular expression for both substitution rules. Thus, the regular expression in the substitution rule becomes the ID123 value when the rules run. This regular expression creates substitution sites in every location where the ID123 value is found in URIs and in POST data. In this example, three substitution sites would be created: RPThelpID123, nameID123, and nameID123=ID123.