Con il seguente codice, è possibile aggiungere un contatore personalizzato. Dopo l'esecuzione dei test, è possibile visualizzare il contatore personalizzato sul report trascinando il contatore personalizzato dai risultati sul report oppure utilizzando la procedura guidata Aggiungi/Rimuovi.
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 {
/**
* Instances of this will be created using the no-arg constructor.
*/
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;
}
}