Using custom code with a Citrix test
You can write custom Java™ code to expand the functions of IBM® Rational® Performance Tester.
Before you begin
About this task
Procedure
- In the test navigator, select the test element location to insert the custom code.
- Click .A custom code test element is created in the test.
-
On the Test Element Details page, click Generate
Code to create a Java™ class based on the
Rational® Performance
Tester API.
You can click View Code to edit an existing class.
- In the Java™ editor,
add the import statement for Citrix tests:
import com.ibm.rational.test.lt.execution.citrix.customcode.*;
- Complete the exec method to specify the function to create.
- Save and close the Java™ class.
Example
The following example is custom code class that can be used as a starting point to evaluate the results of a synchronization point. You can use this template to write a class that performs a synchronization when image synchronization and window-event synchronization are not practical for your test.
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;
}
The following example demonstrates how you can record a screen capture during playback for debugging purposes. The screen capture is recorded in the test log and can be viewed in the Citrix image synchronization view.
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;
}