How loops affect the state of virtual users
About this task
However, in certain instances, you might want to clear all cookies cached for a particular virtual user. For example, if you want each iteration of a loop to appear as a new user, you must reset the cache. If you do not, although the test completes, verification points that you have set within the test may fail.
There are two ways to reset the cookie cache, and each way has different effects.
To reset the cookie cache when looping in the schedule, or when the test follows another test in the schedule, use the following method. This resets the cache whenever the test is entered. Even if your tests do not loop, use this method if you are running back-to-back tests or Siebel tests.
- In the Test Navigator, browse to the test and double-click it. The test opens.
- On the HTTP options page, select Clear cookie cache when the test starts.
Procedure
To reset the cookie cache from one loop iteration to the next when you have put a loop around the entire contents of the test, and the loop is inside the test, add custom code to the test and call an API, as follows:
Example
package test;
import com.ibm.rational.test.lt.execution.http.util.CookieCacheUtil;
import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
public class Class1131739398417 implements
com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {
public Class1131739398417() {
}
public String exec(ITestExecutionServices tes, String[] args) {
CookieCacheUtil.clearCookieCache(tes);
return null;
}
}