Assert Functions
Using the assert functions (asserts), you can easily check whether or not the response of the DUT corresponds to the expected response. This allows you to have the unit test implicitly respond to the test result.
Every assert function returns a result of the check as BOOL, where TRUE
means a successful check and FALSE
means a failed check. Optionally, you could define an error text which is output as a message in case of an error.
To check several different conditions one after the other, typically one assert call per condition is used as a single statement. If the condition of an assert call does not apply, then the error outputs of the test POU are automatically written accordingly and the following assert calls are no longer executed.
Sometimes it can also be useful to use compound conditions in asserts, for example when the control flow of the test logic has to depend on several conditions. The only correct way to create a compound condition with asserts is to use the AND_THEN
statement.
IF (Assert_Bool_IsTrue(^THIS, value1, "") AND_THEN Assert_Bool_IsFalse(^THIS, value2, "")) THEN // do something END_IF
Important
If you use a test POU of type ETrigA
and want to use assert functions, then you need to implement the missing interfaces HandleAssertResult
and HasError
in the test POU. This is done by means of the Implementing Interfaces command in the context menu. Furthermore, check the test POU directly to change the TM.Testcase
scheme.
For more information, see: Obsolete Test POU Implementations
Asserts for Bool
Name | Description |
---|---|
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
Asserts for numeric data types
Name (*) | Description |
---|---|
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
(*) For the name, the TYPE
placeholder has to be replaced with the default IEC data type from the table below
| IEC data type |
| IEC data type |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Asserts for String
Name | Description |
---|---|
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
Asserts for WString
Name | Description |
---|---|
| Successful when the |
| Successful when the |
| Successful when the |
| Successful when the |
Asserts for Array
The set of provided assert functions is limited for specific data types:
Date and time types: No array assert functions available
BOOL: Full set of array assert functions except
ContainsOneOf
,ContainsAllOf
, andContainsNoneOf
.String, integer, floating point types: Full set of array assert functions (as follows).
Example: Full set of assert functions for STRING
arrays
Name | Description |
---|---|
| Successful when all of the following conditions are fulfilled:
|
| Successful when at least one of the following conditions is not fulfilled:
|
| Successful when the STRING |
| Successful when the STRING |
| Successful when at least one element of the |
| Successful when no element of the |
| Successful when all elements of the |
| Successful when all of the following conditions are fulfilled:
|