Scheme for Single Test POUs
Defining a test POU
To define a test POU for a single test case, a function block has to be written which follows a specific scheme and contains the test logic. The most important characteristic of a test POU is the {attribute 'test'}
attribute. Other characteristics of the scheme can be found in the interface convention. You can follow the scheme very easily by using the wizard to create a test POU.
Support during implementation
When you use the wizard to add a unit test, you will be provided with a sample implementation. The wizard will create a working example if you enable the Add implementation template option.
Basic test case function
POUs which are decorated with the compiler directive {attribute 'test'}
, are automatically detected during test execution and compiled with the testee into a test application. The test application is executed. At that time, the POU (according to the convention of a ETrigA
POU) is called as long as its xBusy
output has the value TRUE
and none of the xDone
, xAborted
, or xError
outputs has the status TRUE
. The sInfo
output can specify a description as to why this test case is not completed without errors.
A test POU created with the wizard encapsulates this behavior in the scheme of the base function block TM.Testcase
(defined in the IEC Unit Test
library): For the execution of the test logic, for example, the Execute
method is available as a frame in which the testee should be stimulated. Easy-to-use assert functions are provided for checking the result and reporting errors.
For more information, see: Implementing a single test POU
Timeouts in test POUs
You use timeouts to define maximum time spans for executing the test. If the value is exceeded, then the system aborts with an error. The remaining test cases are skipped. You define the timeouts in the wizard in the Add Unit Testdialog.
Test Case Name
With the optional entry of a test case name, you can give the test case, which has been implemented in the test POU, an alternative name (default: POU name of the test POU). You can use this name in the IEC Unit Test test element to select/except the test case like the POU name. The test case name is displayed in the test report, if applicable.
For more information, see: Pragmas in Test POUs
Test Case Category
Test cases can be organized into categories with which they can be selected/excluded collectively in the IEC Unit Test element. A test case can belong to multiple categories.
For more information, see: Pragmas in Test POUs
Interface convention
The interface convention is automatically followed by a test POU, which has been created with the wizard and maintains the scheme of TM.Testcase
, and is automatically evaluated by the IEC Unit Test test element. The interface convention is therefore interesting when a test POU has to be triggered manually, for example for debugging. In addition, the Pragmas in Test POUs apply.
Name | Data Type | Scope | Optional | Description |
---|---|---|---|---|
|
|
| Starts and checks the execution of the POU | |
|
|
| Aborts the test according to the CAA Behavior Model | |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
| X |
|
|
(Unicode) |
| X | Additional string information for the test report |
|
|
| X | Value of the error description enumeration ( Requirement: The test case was aborted with an error. |