将定制代码用于 Citrix 测试

您可以编写定制 Java™ 代码来扩展 IBM® Rational® Performance Tester 的功能。

开始之前

编写定制代码需要 Java 编程知识,还需要使用 Rational Performance Tester API。请参阅使用定制代码执行测试执行以获取更多信息。

关于此任务

要将定制代码用于测试同步,请执行以下操作:

过程

  1. 在“测试导航器”中,选择要插入定制代码的测试元素位置。
  2. 单击插入 > 定制代码 这将在测试中创建定制代码测试元素。
  3. 在“测试元素详细信息”页面上,单击生成代码以根据 Rational Performance Tester API 创建 Java 类。 您可以单击查看代码以编辑现有类。
  4. 在 Java 编辑器中,为 Citrix 测试添加导入语句:import com.ibm.rational.test.lt.execution.citrix.customcode.*;
  5. 完成 exec 方法以指定要创建的功能。
  6. 保存并关闭 Java 类。

示例

以下示例是可用作评估同步点结果的起点的定制代码类。您可以使用此模板编写一个类,用于在图像同步和窗口事件同步对于您的测试不切实际时执行同步。

import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
import org.eclipse.hyades.test.common.event.VerdictEvent;
import com.ibm.rational.test.lt.execution.citrix.customcode.CitrixCustomCodeImpl2;
import com.ibm.rational.test.lt.execution.citrix.customcode.ICitrixCustomCode2;

public String exec(ITestExecutionServices tes, String[] args) {
		ICitrixCustomCode2 thisCode = new CitrixCustomCodeImpl2(tes);

		// to get the last VP status
		int verdict = thisCode.getLastVerificationPointVerdict();
		if (verdict != VerdictEvent.VERDICT_PASS) {
	
				// this example reports a message but must be adapted to your specific needs
				tes.getTestLogManager().reportMessage("last VP status: " + thisCode.verdictEventToString(verdict));

	}
		return null;
}

以下示例说明如何能够在回放期间记录截屏来用于调试目的。截屏记录在测试日志中,并且可以在“Citrix 图像同步”视图中进行查看。

import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices; 
import com.ibm.rational.test.lt.execution.citrix.customcode.*;

public String exec(ITestExecutionServices tes, String[] args) { 
	
		ICitrixCustomCode2 thisCode = new CitrixCustomCodeImpl2(tes);
	
		// To capture and log the full screen: 
				session.putAsset(currentAsset);  
	
		// To capture and log a part of the screen: 
		// thisCode.logPartialScreenCapture(x, y, width, height); 
	
		// To capture and log a part of the screen to a file: 
		// thisCode.savePartialScreenCapture(filename, x, y, width, height); 
	
		return null;
}

下一步做什么

创建定制代码测试后,可以照常运行测试。如果需要调试测试,那么可以在执行期间使用监视面板来插入断点或与 Citrix 环境交互。

反馈