Rubrique précédente: Custom CompanionsRubrique suivante: Deploy a New Companion


Create a New Companion

Follow these steps:

  1. Create a Java class that extends com.itko.lisa.test.SimpleCompanion.

    This class provides LISA all the information that is required to create, edit, and execute your companion logic.

    public class AllowedExecDaysCompanion extends SimpleCompanion implements Serializable
    {
     
    }
    

    Ensure that you implement Serializable. This is important when your companion is used in remotely staged tests.

  2. Implement the required getTypeName method.

    This method provides the name that is used to identify the companion in the model editor.

    public String getTypeName()
    {
        return "Execute Only on Certain Days";
    }
    
  3. Implement the getParameters method.

    This method that provides LISA with the parameters you need for your companion to be executed. Also call the superclass implementation of this method. The model editor allows you to edit the parameters that are shown here. These parameters are given to you at the time of execution. You do not have to implement this method if your companion does not require parameters.

    public ParameterList getParameters()
    {
        ParameterList pl = super.getParameters();
        pl.addParameter( new Parameter( "Allowed Days (1=Sunday): ", DAYS, "2,3,4,5,6", String.class ) );
        return pl;
    }
    
  4. Implement the testStarting method.

    LISA calls this method with the parameters you requested. If an error occurs or you otherwise want to prevent the test from executing normally, throw a TestRunException.

    protected void testStarting( ParameterList pl, TestExec testExec ) 
        throws TestRunException
    
  5. Implement the testEnded method.

    LISA calls this method with the parameters you requested. You have an opportunity to perform any post-execution logic for the test.

    protected void testEnded( ParameterList pl, TestExec testExec ) 
        throws TestRunException