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 substitution rule for that field, and then insert a Create reference rule as a child of the Create 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 substitution rule. See Creating a substitution with data correlation rules to learn more about creating a Create substitution rule.
  3. Right-click the Create substitution rule, and then click Insert Item > Create reference. If the reference exists, select Find reference instead of Create reference. A Create reference or Find reference rule is inserted as a child of the Create substitution rule. The value of the substitution that the parent substitution rule creates is inserted into the regular expression for the reference rule when the rule is run. See Creating a reference using data correlation rules to learn more about creating a Create reference rule.

Results

When you re-correlate 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. Then, add a rule that creates a reference as a child of the substitution rule. The regular expression for the reference rule is docHelpName=(.*?)>. Because the substitution rule locates the datacorrelation value, and because the reference rule is a child of the substitution rule, the datacorrelation value is used as input for the regular expression in the reference rule. Thus, the regular expression in the reference rule is docHelpName=datacorrelation>. This regular expression ensures that the correct reference is linked to the substitution site.

Feedback