Skip to main content

Pragmas in Test POUs

The following pragmas identify a program or function block as a test POU and define test case properties.

Table 75. Simple test

Pragma

Optional

Description

{attribute 'test'}

Identifies a function block or program as a test POU

When a test is executed, the test POUs are compiled with the testee into a test application.

{attribute 'testcasename' := 'N_001:CountDown'}

X

Test case name

{attribute 'testcategory' := 'BasicTests,CTD'}

X

Test case categories which are assigned to the test case (comma-separated)

{attribute 'testcasetimeout' := '5000'}

X

Timeout of the test case (in milliseconds)

Default value: 15 seconds



Table 76. Multitest

Pragma

Optional

Description

{attribute 'test' := 'multitest'}

Identifies the function block as a test POU of a multitest

{attribute 'testcasename' := '#n:CountDown'}

X

Test case name

If the name contains the placeholder #n, then the consecutive number of the test case is inserted there. Either this attribute or the output parameter sTestCaseName is defined.

{attribute 'testcategory' := 'BasicTests,CTD'}

X

Comma-separated list of test case categories of the test case

{attribute 'testcasetimeout' := '5000'}

X

Timeout (in milliseconds) which is applied individually for each test case without its own timeout (and actions xGetTestInfo)

{attribute 'testcasecount' := '5000'}

X

Number of test cases

If the attribute is not available, then the output xTestCaseCount of the test POU is set at runtime to the appropriate number (by specifying xGetTestInfo xTestCaseIndex).

{attribute 'testcasegroup' := 'Group 1.Sub Group 2.Sub Group 3'}

X

Name of the test case group

Example: 'Group 1.Sub Group 2.Sub Group 3': Group with two parent groups

{attribute 'testcasegrouptimeout' := '300000,60000,30000'}

X

Timeout for a test case group

Used together with the pragma {attribute 'testcasegroup'}

Example: Group 1.Sub Group 2.Sub Group 3

At least one of the test POUs from the group has declared the value and contains this pragma. If tests of the group have declared different values, then this leads to an error and the test POUs of the entire group are not performed.

The values of the timeouts are assigned based on the lowest group. If a value is missing, then the test case group does not get a defined timeout. The asterisk character (*) is used as a placeholder for undefined values.

Example 1

{attribute 'testcasegroup' := 'MyTable.Group 1.Subgroup 2'}
{attribute 'testcasegrouptimeout' := '300000,60000,30000'}

=> MyTable = 300000 (5 min), Group 1 = 60000 (1 min), Subgroup 2 = 30000 (30 s)

Example 2

{attribute 'testcasegroup' := 'MyTable.Group 1.Subgroup 2'}
{attribute 'testcasegrouptimeout' := '300000,*,30000'}

=> MyTable = 300000 (5 min), Group 1 = N/A, Subgroup 2 = 30000 (30 s)

Example 3

{attribute 'testcasegroup' := 'MyTable.Group 1.Subgroup 2'}
{attribute 'testcasegrouptimeout' := '60000,30000'}

=> MyTable = N/A, Group 1 = 60000 (1 min) , Subgroup 2 = 30000 (30 s)