변수 값 저장과 검색

getValue() 메소드와 setValue() 메소드를 사용하여 변수의 값을 저장하고 검색할 수 있습니다. 지정하는 스토리지 위치에 따라 테스트에서 변수를 공유하거나 변수를 현재 테스트에 로컬로 저장할 수 있습니다.

getValue() 메소드와 setValue() 메소드를 사용하여 하나의 사용자 정의 코드 호출에서 변수에 여러 값을 저장할 수 있습니다. 그런 다음 대체를 여러 사용자 정의 코드 요소에서 작성하는 대신 변수에서 작성할 수 있습니다.

예를 들어, 응답에 3개의 값 ID, 서적 제목, 가격이 있다고 가정합니다. 응답에서 이 세 값을 모두 읽은 후 사용자 정의 코드를 사용하여 변수 id, title, price를 설정할 수 있습니다. 그런 다음 변수마다 사용자 정의 코드를 작성하는 대신 테스트에서 필요에 따라 세 개의 변수에서 값을 대체할 수 있습니다.

참고: 메소드에 전달되는 스토리지 위치는 변수 선언 시 사용된 스토리지 위치와 일치해야 합니다.
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;
    }

피드백