Scheme for Multitest POUs
Defining a test POU
If your test consists of multiple uniform test cases, then you can implement one multitest POU instead of many single test POUs. Multitest POUs follow a scheme similar to test POUs for single test cases and are flagged with the {attribute 'test' := 'multitest'}
attribute. Other characteristics of the scheme can be found in the Interface convention. You can follow the scheme easily by using the wizard to create a test POU.
For more information, see the Examples.IecUnitTest
example
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 as long as you enable the Add implementation template option.
Basic test case function
Before the actual test execution (xGetTestInfo := FALSE
), information is collected about the individual test cases of the POU. In this phase, the input xGetTestInfo
has the value TRUE
. With the value -1
at the diTestCaseIndex
input, the number n of test cases is queried at the diTestCaseCount
output. Then there is a sequence of queries that varies the values of the diTestCaseIndex
input from 0
to n-1
in order to request the sTestCaseName
, sTestCaseCategories
, and diTestCaseTimeout
information for each test case. Each query is performed by the Test Manager in a closed cycle from xExecute := TRUE
, wait for xDone
, or xError
and reset of the xExecute
input to FALSE
.
Therefore, the test is executed as a sequence of closed cycles (xExecute
to xDone
or xError
) that varies the diTestCaseIndex
input from 0
to n-1
. At that time, the xGetTestInfo
input is always left at the value FALSE
. A description can be output for the test report by means of the sInfo
output. In case of error (xError := TRUE
), the error code can be included in the test report by means of eError
, and a description of the error situation by means of sError
. If possible, the symbolic name of the error code is included in the log.
A test block which has been created with the wizard encapsulates this behavior in the scheme of the base POU TM.BaseMultiTest
(defined in the IEC Unit Test
library). For the execution of the test logic, the prvCyclicAction
method is available as a frame in which the testee should be stimulated. Furthermore, 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.BaseMultiTest
, 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 | Type | Scope | Optional | Description |
---|---|---|---|---|
|
|
| Starts and checks the execution of the POU | |
|
|
| Aborts the test according to the | |
|
|
|
They may take several cycles also for actions with | |
| Integer data type |
| X | Number of test cases provided by this test POU If the directive |
| Integer data type |
| Test case which is processed | |
|
|
| X | Test case name which can be read by means of If the name was specified by a direct line and is not an empty string, then it is included in the test report. |
|
|
| X | Additional test categories assigned to the specified individual test case |
| Integer data type |
| X | Timeout of the test case (in milliseconds) If the value is greater than 0, then it is the timeout for this test case (and overwrites any test cases for each directive). Negative values are reserved for future use and lead to abort. |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
| X | Additional text information for test report |
| Enumeration |
| X | Enumeration value of the error description Requirement: An error has occurred. |
|
|
| X | More detailed textual error description Implemented also for function blocks which are not multitest-capable Requirement: An error has occurred. |
|
|
| X | Warning message for the test report Implemented also for function blocks which are not multitest-capable |
|
|
| X | Failure mode (error handling) of the test case Implemented also for function blocks which are not multitest-capable |