Editing test cases

The test case editor enables you to visually design test cases associated with your source code and to create variable checks.

About this task

The test case editor is made of two panes:
  • The Activity diagram displays a flow chart describing the blocks that are required in the test case. If necessary, you can add and remove blocks, conditions and arrow lines to edit the activity diagram. The test case criteria are contained in one or several Check blocks.
  • The Details pane contains information about the selected block. For example, click the Inits & Stubs block to edit the initialization parameters, headers, and stubs required to run the test case.
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 test case and expands automatically all parent nodes.

The main objective of editing a test case is to define the variable and structure checks in the Check block.

Procedure

  1. In the project explorer, open a test case.
  2. In the Activity diagram, create the necessary blocks for the test case and connect them with connector lines.
    The default flow chart contains an Init. & Stubs block, followed by a Code block, followed by a Check block.
    1. Click Create Code Block Create Code Block button or Create Check Block Create Check Block button buttons to create new blocks.
      Code blocks can be used to run portions of C code inside the test case. Check blocks contain the test criteria for the variables under test.
    2. Click Create Decision Block Create Decision Block button to make the execution of other blocks conditional.
      You can combine code blocks and decision blocks to create loops.
    3. Click Create ConnectorCreate Connector button to connect new blocks in the diagram.
      Ensure that all blocks are properly connected.
  3. On the Requirements page, document requirements that are specific to your program or quality process. You can enter the name, a comment, and if a web page exists in your requirement management tools, enter the link to the web page that displays the requirement. You can also add requirements that come from a .cvs file.
    1. To add a requirement, click Add requirement and enter a name for the requirement. You can modify the name. The table is editable, you can modify the name of the requirement, add a comment and add a link to a web page that is used as requirement in the table.
    2. Click Duplicate a requirement to duplicate a requirement in the table.
    3. Click View requirement in a browser to view the requirement in a browser.
    4. Click Add a requirement from a list to add a requirement from a list. This button is available only if you previously set the preferences to retrieve the requirements from a .cvs, .xml, or .reqif file. For more information, see Link Tests to Requirements. The requirements are filtered by name and comment. In the test reports, you can find the list of tests associated with the list of requirements.
  4. In the Activity diagram, select a check block.
    The Checked Variables table displays the variables and structures contained in the function under test.
  5. For each variable or structure, specify an initial value and an expected value.
    These values can be simple values, multiple values (ranges, series) or C structures.
    1. In the Checked Variables table, select a variable Initial Expression cell that you want to set and click the menu button (Menu button) to specify a single Value, Multiple values, a Series, whether to Use Structure Fields, or to apply No Change to the initial value. You can also choose constructor in the list, which means that you choose a constructor other than the default one. A constructor is a set of methods that has the same name as the class it belongs to. It is used to initialize the current instance and it is available only for a variable which is an instance of C ++ class.
      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. To select a new constructor, click the menu button (Menu button) and select a value in the drop-down list.
      The quick editor area adapts to the selected data type or entry mode.
    3. In the Checked Variables table, select a variable Expected Expression cell that you want to set and click the menu button Create Connector button to specify an expected value or range.
      See Variable expected value expressions for more information.
    Note: By default, the Obtained Value column displays the actual value for the variable obtained during the last run. Use the Available Runs list, located at the top of the test case editor, to display the actual values obtained during a specific run.
  6. When you have finished editing the test case, click Save and close the test case.