Editing test harnesses

Use the test harness editor to edit test harnesses.

About this task

The test harness editor is made of two panes:
  • The Activity diagram displays a flow chart describing the blocks that are required in the test harness. 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. You can also activate or deactivate a test case call in a test harness. Click a test case block in the Activity diagram, and click the active test case icon in the test case block to deactivate a test case call, or click the deactivate test case call icon to activate a test case call.
  • The Details pane contains information about the selected block. For example, click a code block to edit the C/C++ source code that you want to insert into the test harness or click the black initialization circle to define the properties of the test harness. If you click a test case block in the Activity diagram, the pane displays all functions/methods and variables used by the test harness.
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 harness and expands automatically all parent nodes.


To edit a test harness:
  1. In the project explorer, open a test harness.
  2. In the Activity diagram, create the necessary blocks for the test harness and connect them with connector lines.
    The default flow chart contains a test case.
    1. Click Insert Test Case Insert Test Case button to add an existing test case into the test harness.
    2. Click the Create Code Block Create Code Block button to add a block containing native C code that can be run between test cases.
    3. 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.
    4. Click Create ConnectorCreate Connector button to connect new blocks in the diagram.
      Ensure that all blocks are properly connected.
  3. On the Context Definition page, ensure that all the source files and libraries required to compile and run the test harness are properly defined.
    • Tested files: These are source files under test. The functions of these components are instrumented and integrated into the test harness.
    • Additional sources: These are dependency files that are added to test harness, but are not tested or instrumented. For example: resource files can be compiled inside a test harness by specifying them as additional files.
    • Linked files: These are source files that are linked with the test harness but are not tested or instrumented.
    • Libraries: These are libraries that are required for the link. For example: math libraries.
  4. On the Build Settings page, you can override the project the build settings.
    See Build configuration settings for information about each of these settings.
  5. On the Stubs page, specify any stub behaviors that you want to replace a function with.
    See Stubbing overview for information about stub simulation.
  6. 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. 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 directly 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.
  7. On the Header Code page, add native C source code that might be required run as a header for the test harness. For example, you could add code to initialize or set the hardware to a specific state before running the test cases.
  8. On the Declarations page, add any global or local variables that need to be set before running the test harness.
    1. Click Add application variable (Add application variable button) to initialize a variable in the test harness.
      Select one of the variables that are declared in the application.
    2. Click Add application variable to simulate (Add application variable button) to simulate a variable in the test harness.
      Select one of the variables that are declared in the application.
    3. Click Add local variable (Add application variable button) to create a local variable for the test harness.
      Specify a name and a type for the new variable.
  9. In the Details pane, select the icon corresponding to the feature that you want to add to the settings of your project: Code coverage, Memory profiling, Performance profiling, Application profiling, Control coupling, Data coupling, Runtime tracing, Static metrics, and Code review.
  10. When you have finished editing, save the test harness.
    Note: You can run the test harness from the editor. For details, see Running a test harness.