Citrix テストでのカスタム・コードの使用

カスタム Java™ コードを作成して、IBM® Rational® Performance Tester の機能を拡張することができます。

始める前に

カスタム・コードを使用するには、Java プログラミングの知識が必要です。また、Rational Performance Tester API を使用する必要があります。 詳しくは、『カスタム・コードによるテストの実行の拡張』を参照してください。

このタスクについて

テスト同期用のカスタム・コードを使用するには、以下のようにします。

手順

  1. テスト・ナビゲーターで、カスタム・コードを挿入するテスト・エレメントの位置を選択します。
  2. 「挿入」 > 「カスタム・コード」とクリックします。 テスト内にカスタム・コードのテスト・エレメントが作成されます。
  3. 「テスト・エレメントの詳細」ページで「コードの生成」をクリックし、Rational Performance Tester API に基づいた Java クラスを作成します。 「コードの表示」をクリックすると、既存のクラスを編集できます。
  4. Java エディターで、Citrix テストの import ステートメント 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: 
	thisCode.logFullScreenCapture(); 
	
	// 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 環境と対話したりすることができます。

フィードバック