In diesem Beispiel wird eine FEHLSCHLAG-Beurteilung protokolliert, wenn die Eingabe für den angepassten Code im aufrufenden Test fehlt. Wenn die erwartete Eingabe vorhanden ist, wird diese in das Ausführungsprotokoll geschrieben und eine PASSIERT-Beurteilung protokolliert. Die Fettformatierung kennzeichnet Zeilen, die zur Schablone hinzugefügt wurden.
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; } }
Übergeordnetes Thema: Tests mit angepasstem Java-Code erweitern