Example: Linking references to substitutions with rules

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

About this task

If you know which field in a request or in POST data must be correlated, write a Create a substitution rule for that field, and then insert a Create a reference rule as a child of the Create a substitution 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 substitution rule. See Creating a substitution with data correlation rules to learn more about creating a Create a substitution rule.
  3. Right-click the Create a substitution rule, and then click Insert Item > Find data source for substitution.
  4. Right-click the Find data source for substitution rule, and then click Insert Item > Create a reference. If the reference exists, select Find a reference instead of Create a reference.
    A Create a reference or Find a reference rule is inserted as a child of the Find data source for substitution rule. To use the value of the substitution extracted by the parent rule, type %subname% for the Regular expression, where subname is the name of the substitution that is created by the parent rule. See Creating a reference using data correlation rules to learn more about creating a Create a reference rule.

Results

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

Example

Assume that a URI in your test is http://host:port/RPThelp/index.jsp?topic=datacorrelation.html. Assume that some of the response data from a previous request includes ...<id=2 docHelpName=recordtest> <id=23 docHelpName=datacorrelation> <id=24 docHelpName=rules>.... Write a rule that creates a substitution site in the URI for datacorrelation and sets the substitution name to helpname. Then, add rules that create a reference as a child of the substitution rule. The regular expression for the reference rule is docHelpName=%helpname%>. Thus, the regular expression in the reference rule evaluates to docHelpName=datacorrelation>. This regular expression ensures that the correct reference is linked to the substitution site.