Editing stubs

The stub editor enables you to visually describe the stub behavior and to define input and output parameters for the stub.

About this task

The test case editor is made of three panes:
  • The Stub Behaviors list displays one or several behaviors for the stub function. You can add new behaviors or duplicate existing behaviors.
  • The Calling Function pane displays the names of components that call the stubbed function.
  • The Details pane contains the input and output values for the selected behavior.
  • The User source code pane contains the user code added to compute a return value for the stub.
Tip: You can find where the edited file is located by clicking on the title of editor or on the header and selecting Navigate > Show In > Project Explorer . The explorer selects the current stub and expands automatically all parent nodes.

The main objective of editing a test case is to define the checks for each stub's call in the tested code.

Procedure

  1. In the project explorer, open a stub.
  2. In the Stub Behaviors list, select the default behavior or create new one.
  3. In the Details section, select a check block. The Checked Variables table displays the variables and structures contained in the function under test.
  4. For each variable or structure, specify an expected value and a return code. These values can be simple values, multiple values (ranges, series) or C structures.
    1. In the Stub call definition table, select a variable Expected Value cell that you want to set and click the menu button Create Connector button to specify an expected value or range. See Variable initial expressions for more information.
    2. To edit single values, multiple values, or series, type the values in the quick edition area line above the table. To specify structure values, edit the individual fields of the structure. The quick editor area adapts to the selected data type or entry mode.
    3. In the Stub call definition table, select a variable return cell that you want to set and click the menu button Create Connector button to specify a return value. This value can be a C native expression. If you want to replace a single value by a section of source code, click on the Code button. The User source code is activated and you can enter your special source code for the stub. Don't forget the return statement to return a value for the calling expression.
  5. When you have finished editing the test case, click Save and close the stub editor.
Feedback