Skip to main content
Version: legacy

Define Method

A method consists of instructions to perform a specific task. Defined methods can be called to use later. For more details regarding how to call a defined method, refer to Method Call Statements.

Note:
  • Once a test step is added as any of the control statements, it is not allowed to change into another keyword.

In manual view

  1. Open a test case in Manual view. Click on the drop-down icon of the Add button, then choose Method.
  2. To add a keyword under a statement, select that statement, then click Add . A test step is created under that statement.
    Define method
    The Method builder dialog appears.

    Method builder dialog

  3. Specify the required information for your method as follows:
    FieldDescription
    NameThe name of the method.
    Return typeThe object type that this method returns after its execution.
    Setup, Teardown optionsSelect any checkbox to indicate whether it should be a setUp or tearDown method. Refer to SetUp() and TearDown() in Manual view for more details.
    Parameter list

    Any parameter needed to pass into the method.

    By clicking on the Insert button, a row will be appended into the grid. You can then change the type and name of the parameter by double-clicking and editing them.

  4. After configuring the method details, click OK.
    A test step representing the recently defined method is added to the test case. You can switch to the script view to define content for the method.
    Define method steps
  5. When you're done, save the test case.

In script view

The Script view of a test case allows you to programmatically define and handle methods using Groovy or Java language. For details about methods in Groovy, refer to Groovy documentation:  Methods .

For example:

  • Method declaration :

    Integer myMethod(def param1, def param2) { return param1 + param2 }
  • Method call :

    myVar = myMethod1(varA, varB)