Guidelines for adjusting data correlation

When you run a test, you might notice that the server is not under the expected load or that your database is not being updated as expected. Incomplete or incorrect data correlation can cause these problems.

To identify data correlation problems:
  1. Use the Potential Correlation Errors view to find missing or incorrect data correlations. See Finding data correlation errors for more information.
  2. Run a test individually or in a schedule with the Log Level for errors, failures, and warnings set to All.
  3. After the run, open the test log as explained in Viewing the test logs.

The data correlation algorithms that are used during test generation are based on well known best practices. However, because these practices continually evolve, various types of errors can occur during automated data correlation:

  • Insufficient correlation: Test values that must be correlated are not. Some possible causes follow:
    • Two parameters that must be correlated have different names.
    • A value must be correlated with a previous value that does not occur in the expected location.
    • A parameter or value must be correlated with a previous parameter or value that does not occur in the test because it is a computed value.
  • Superfluous correlation: Unrelated test values are correlated.
  • Incorrect correlation: Test values that must be correlated are correlated incorrectly.

Insufficient correlation: Parameters have different names or occur in unexpected locations

When two parameters that must be correlated have different names, automated data correlation does not recognize that the two parameters are related. For example, consider this request: http://www.example.com?id=12345. Suppose that this request must be correlated with the server response that contains customer_ID=12345, not ID=12345. In this case, the ID parameter must be correlated with customer_ID.

Data correlation typically links a response value that was returned from the server with a subsequent request value. The automated correlation algorithms search in the URL and the POST data for potential matches; however, other schemes for returning parameters are possible. For example, consider this request: http://www.example.com?id=12345. Suppose that this request must be correlated with the server response that contains the name and entity pair href name="customer_ID" entity="12345", not ID=12345. In this case, the ID parameter must be correlated with name="customer_ID" and value 12345 must be correlated with entity="12345".

Here are some additional causes of insufficient correlation:
  • SOAP designates correlation parameters in external XML files. The correlation algorithms cannot correlate parameters in the external file with parameters in the test.
To manually correlate data in these cases:
  1. In the test editor, use search or browse to locate the two parameters for correlation.
  2. Navigate to the parameter that occurs later in the test, and select the parameter. This is the substitution site.
  3. In the Test Data Sources window, click the References tab.
  4. Select the data source to use as a reference, and then click Substitute From.

Insufficient correlation: One parameter is unnamed

Sometimes a parameter or value must be correlated with a previous parameter or value that is not named in the test, because it is computed, for example, by a JavaScript program. In this case, in order to correctly correlate the data, you must understand how and where the parameter or value is computed, and then use a custom code block. See Extending test execution with custom code for more information about custom code.

For example, consider the web address http://www.example.com?login_stamp=12345_Apr_11_07, where the value for login_timestamp is the concatenation of the login ID and the current date. In this case, you must generate a custom code that concatenates the login ID and the date.

For another example, suppose that the server returned the login ID and date as separate entities: href "customer_id=12345" Date="Apr_11_07". In this case, you can put these parameters in separate references and, in subsequent requests that use customer ID and date, substitute them separately.

Superfluous correlation

Automated data correlation is based on pattern matching: A parameter or parameter value is correlated with a subsequent parameter or parameter value with an exact or similar name. But sometimes parameters with exact or similar names are in fact unrelated. In the best case, unneeded correlation is either harmless or adds a slight load that is inappropriate. In the worst case, the application does not expect a correlation and fails during playback.

To remove a superfluous data correlation:
  1. In the test editor, search or browse to locate the substitution site that must not be correlated. By default, purple letters indicate correlated data.
  2. Right-click the substitution site.
  3. Click Remove Substitution.

Incorrect correlation

A parameter that requires data correlation might occur many times throughout a test. For example, a session ID parameter that is used initially when a user logs in might also be used in every subsequent request. If multiple instances of a parameter in a test are not same, the correlation algorithms might use the wrong instance.

With the HTTP Test Generation preferences, you can optimize automatic data correlation for accuracy or for efficiency.
  • Accuracy: Each occurrence of a parameter is correlated with the nearest previous occurrence. This is the default setting.
  • Efficiency: Each occurrence of a parameter is correlated with a single previous occurrence.
Note: If you do not manually apply a correlation in the Referer field in an HTTP request header, then the Referer field is automatically correlated as needed. If you manually apply a correlation in the Referer field in an HTTP request header, then no automatic correlation is performed.
Incorrect correlations are more likely to happen when Optimize automatic data correlation for execution is set to Efficiency. To fix an incorrect correlation:
  1. In the test editor, search or browse to locate the value that is incorrectly correlated.
  2. Right-click the substitution site.
  3. Click Remove Substitution.
  4. Right-click the substitution site again.
  5. Click Substitute, and select the correct parameter.

Generally, the HTML response content after the recording would look like <input type="username" name="User" id="aaa" value="John"/>. Some applications dynamically update the name attribute. So, when you play back the test the HTML response content would look like <input type="username" name="idt020" id="aaa" value="John"/>. Because the name attribute is changing dynamically, data correlation would not occur and the playback would fail.

Such correlations are the result of the tool using the name attribute as the basis for correlating other attributes in the response code instead of the ID. To correlate the responses based on ID, select ON in Window > Preferences > Test > Test Generation > HTTP Test Generation > Data correlation types > Prioritize correlation based on ID.