Skip to main content

Controlling Test Case Execution with Categories

Categories and their impact

You can execute slightly modified tests with customized test scripts and test projects by using categories. To do this, you categorize the test POUs contained in the test project and deactivate the test POUs of a category for a test in the test script.

By specifying the categories in the IEC Unit Test test element of the test script, a mechanism is enabled for filtering test POUs. Test POUs with these categories are ignored when the test application is generated. As a result, the code contained in the generated test application depends on the specified categories.

Declaration of categories

  • Test POUs are categorized by adding the pragma {attribute 'testcategory' := '<categories>'} to their declaration and assigning a category name to the pragma attribute. Multiple categories are separated by commas. As a result, a test POU can be assigned to multiple categories.

    Tip

    When you use the wizard to create a unit test, you can define the test case category in the Add Unit Test dialog.

  • You can categorize a test table globally by specifying a category on the Global Information tab in the Categories of the tabular editor. Multiple categories are separated by commas. Test case groups and test cases can be categorized locally. To do this, open the Properties dialog and edit the Categories setting.

Deactivation of categories

  • To ignore a category during generation, specify the test element IEC Unit Test in the test script as follows: Specify the categories to be ignored in the Excluded categories input field of the IEC Unit Test tab.

Customizing a unit test

Procedure. Customizing a test project
  1. Open the test project.

  2. Decorate test POUs with the pragma {attribute 'testcategory':='<category_name>'}.

    The category <category_name> is declared and the test POU is assigned to this category.

Procedure. Customizing a test script
  1. Open the script.

  2. Select the test element IEC Unit Test.

    The IEC Unit Test tab opens on the left side.

  3. In the Excluded categories input field, specify the categories that should not be tested.