Previous Topic: Custom CompanionsNext Topic: Deploy a New Companion


Create a New Companion

You can create a companion that extends the predefined SimpleCompanion.

Follow these steps:

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

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

    public class AllowedExecDaysCompanion extends SimpleCompanion implements Serializable
    {
     
    }
    

    Implement Serializable when your companion is used in remotely staged tests.

  2. Implement the required getTypeName method.

    This method provides the name that identifies the companion in the model editor.

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

    This method provides any parameters needed for your companion to execute. 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. Implement this method only if your companion requires 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.

    DevTest calls this method with the parameters you request. 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.

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

    protected void testEnded( ParameterList pl, TestExec testExec ) 
        throws TestRunException
    
  6. (Optional) Implement the setLongMsg method to integrate into Portal Test Monitoring facility.

    You can provide a detailed message for the companion.

    public void setLongMsg( boolean isStarting, String msg )