レポートへのカスタム・カウンターの追加

カスタム・コードを使用して、パフォーマンス・レポートにカスタム・カウンターを追加することができます。 テストを実行した後、カスタム・カウンターからの結果は、デフォルトのパフォーマンス・テスト・カウンター (バイトおよびページ・カウンターなど) と同じ方法で自動的に集約されます。 カスタム・カウンターの集約は、すべてのエージェント・コンピューターから結合されます。
注: カスタム・カウンターを「実行」「ページ」、または他のルート・エレメントの下に配置しない限り、「実行統計カウンターの追加/除去」ウィンドウにはカスタム・カウンターについての情報は含まれません。

以下のコードを使用して、カスタム・カウンターを追加できます。 テストを実行した後、カスタム・カウンターを結果からレポートにドラッグするか、「追加/除去」ウィザードを使用することによって、カスタム・カウンターをレポートに表示することができます。

package CustomCounter;

import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;

/**
 * @author unknown
 */
public class Class implements
		com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {

	/**
	 * no-arg コンストラクターを使用してこのインスタンスを作成する。
	 */
	public Class() {
	}

	/**
	 * For javadoc of ICustomCode2 and ITestExecutionServices interfaces, select 'Help Contents' in the
	 * Help menu and select 'Extending Rational Performance Tester functionality' -> 'Extending test execution with custom code'
	 */
	public String exec(ITestExecutionServices tes, String[] args) {tes.getStatisticsManager().getStatTree().getDistribution(new String[]{"Custom Counter","MyTest","MyValue"})
		.submitDataPoint(Double.valueOf(Math.random()*100.).longValue());

		return null;
	}

}

フィードバック