Implementing code generation for error handling

During code generation, test elements are translated into code language elements. You must implement code generation for new error-handling methods.

To learn more about code generation, see Extending code generation.

Complete these steps to implement code generation for objects that do not generate errors:

  • For Script objects, add the <PARAM name="codegen.core.attributes"> parameter to the creation template for the method. For KAction objects, add the <PARAM name="codegen.core.attributes"> parameter to the execute() method.
  • Add a call to the translateCoreAttributes() method. For example, the LTTestScriptDefinition class now includes this call:
    LTTestTranslator.translateCoreAttributes(scriptTemplate, null, (CBActionElement)test);

Complete the following steps to implement code generation for methods that generate errors, such as connection failures and authentication failures:

  • Add the <PARAM name="errorBehavior"> parameter to the creation template for the method.
  • Add a call to the translateErrorBehavior() method. For example, code generation for the BasicAuthentication object in HTTP includes these calls:
    		CBError err = (bAuth.getCBErrors().size()==0)?null:(CBError)bAuth.getCBErrors().get(0);
    		translateErrorBehavior(err, bAuthElem, ILanguageElement.TEMPLATE_CREATION);