This example logs a fail verdict if the custom code's input from the calling test is missing. If the expected input is present, the input is written to the execution history and a pass verdict is logged. Bold indicates lines added to the template.
package custom; import com.ibm.rational.test.lt.kernel.logging.IKLog; import org.eclipse.hyades.test.common.event.* /** * @author unknown */ public class LogVerdictExample implements com.ibm.rational.test.lt.kernel.custom.ICustomCode { /** * Instances of this will be created using the no-arg constructor. */ public LogVerdictExample() { } /** * @see com.ibm.rational.test.lt.kernel.custom.ICustomCode#exec(IKLog, java.lang.String[]) */ public String exec(IKLog log, String[] args) { if (args == null) { log.reportVerificationPoint("Failure",VerdictEvent.VERDICT_FAIL,"No input values found.",VerdictEvent.REASON_SEE_DESCRIPTION); } else { String s = ""; for (int i=0; i < args.length; i++) { s = s + args[i]; } log.reportMessage("Input argument to this custom code is: " + s); log.reportVerificationPoint("Success",VerdictEvent.VERDICT_PASS,"The response included your country code."); } return null; } }
Parent topic: Extending tests with custom Java code