É possível usar os métodos getValue() e setValue() para armazenar vários valores nas variáveis em uma chamada de código customizada. VocêÉ possível então criar substabelecimentos de variáveis em vez de vários elementos de códigos customizados.
Por exemplo, assuma que uma resposta contenha três valores: id, título do livre e preço. Você pode ler todos os três valores da resposta e depois usar código customizado para configurar as variáveis id, title e price. Em seguida, é possível substituir os valores das três variáveis no teste, conforme necessário, em vez de precisar gravar código customizado para cada variável.
package customcode;
import com.ibm.rational.test.lt.kernel.IDataArea;
import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
/**
* For Javadoc information on the ICustomCode2 and ITestExecutionServices interfaces,
* see the 'Extending test execution with custom code' help topic.
*/
/**
* @author IBM Custom Code Samples
*/
public String exec(ITestExecutionServices tes, String[] args) {
tes.getValue("myVar", tes.STORAGE_USER); // This retrieves a value from a test for the variable called myVar. The storage area is shared between tests.
tes.getValue("myLocalVar", tes.STORAGE_LOCAL); // This variable is stored locally, per test.
tes.setValue("myVar", tes.STORAGE_USER, "myNewValue"); // Change the value of the variable myVar, which is shared between tests, to myNewValue.
tes.setValue("myLocalVar", tes.STORAGE_LOCAL, "myLocalNewVar"); // Change the value of the local variable to myLocalNewVar.
return null;
}