CreateAssertionErrorMessageForStandardDatatype (FUN) ¶ FUNCTION CreateAssertionErrorMessageForStandardDatatype Helper function to create an error message for failed assertions of standard datatypes. Hint: if wsErrorMsg is used, it is recommended to change the value of the library parameter Constants.WSTRING_LENGTH . InOut: Scope Name Type Comment Inout wsAssertError WSTRING(Constants.WSTRING_LENGTH) Inout Const wsActualValue WSTRING(Constants.WSTRING_LENGTH) The actual value as WSTRING wsReferenceValue WSTRING(Constants.WSTRING_LENGTH) The reference value as WSTRING wsAssertOperator WSTRING(Constants.WSTRING_LENGTH) The assert operator e.g. Strings.EQUAL or Strings.CONTAINS wsErrorMsg WSTRING(Constants.WSTRING_LENGTH) A custom error message that should be appended. If no message is provided the “Additional information” part will not be added to the returned error.
CreateAssertionErrorMessageForStandardDatatypeSingleValue (FUN) ¶ FUNCTION CreateAssertionErrorMessageForStandardDatatypeSingleValue Helper function to create an error message for failed assertions of standard datatypes that only expect an actual value. Hint: if wsErrorMsg is used, it is recommended to change the value of the library parameter Constants.WSTRING_LENGTH . InOut: Scope Name Type Comment Inout wsAssertError WSTRING(Constants.WSTRING_LENGTH) Inout Const wsActualValue WSTRING(Constants.WSTRING_LENGTH) The actual value as WSTRING wsAssertOperator WSTRING(Constants.WSTRING_LENGTH) The assert operator e.g. Strings.IS_TRUE wsErrorMsg WSTRING(Constants.WSTRING_LENGTH) A custom error message that should be appended. If no message is provided the “Additional information” part will not be added to the returned error.
CreateAssertionErrorMessageNonEqualArrayBounds (FUN) ¶ FUNCTION CreateAssertionErrorMessageNonEqualArrayBounds Helper function to create an error message for non-equal bounds of an array. InOut: Scope Name Type Comment Inout wsAssertError WSTRING(Constants.WSTRING_LENGTH) Input diExpectedBound DINT the upper or lower bound of the reference array diActualBound DINT the upper or lower bound of the actual array xIsLowerBound BOOL if set to TRUE the error message contains Lower bounds otherwise Upper bounds diDimension DINT the dimension in which the bounds differ
IBaseIecUnitTest (ITF) ¶ INTERFACE IBaseIecUnitTest This interface is required to use the assertion functionality for IecUnitTests Methods: HandleAssertResult HasError Structure: HandleAssertResult (Method) HasError (Method)
Interfaces ¶ IBaseIecUnitTest (Interface) HandleAssertResult (Method) HasError (Method)
IBaseIecUnitTest.HasError (METH) ¶ METHOD HasError : BOOL This method should only return xError = TRUE InOut: Scope Name Type Return HasError BOOL
IBaseIecUnitTest.HandleAssertResult (METH) ¶ METHOD HandleAssertResult : BOOL This method should handle the error outputs used to evalutate the success of the unittest The default implementation should look like: CASE eAssertion_Result OF ASSERTION_RESULT.ASSERTION_FAILED: xError := TRUE; iError := 1; sInfo := wsErrorMsg; wsInfo := wsErrorMsg; wsError := wsErrorMsg; ELSE RETURN; END_CASE InOut: Scope Name Type Return HandleAssertResult BOOL Input eAssertion_Result ASSERTION_RESULT wsErrorMsg WSTRING(Constants.WSTRING_LENGTH)
Testcase (FB) ¶ FUNCTION_BLOCK Testcase EXTENDS Testcase_Base IMPLEMENTS IBaseIecUnitTest Base class for a simple test case. To implement a testcase: Extend your test from this function block Add {attribute 'test'} to the FB, so that it is identified as a test Optionally add any of the following attributes as desired {attribute 'testcategory':='<add categories here>'} {attribute 'testcasename':='<new name>'} to use a testcasename other then the FB name {attribute 'testcasetimeout':='<timeout in ms>'} to alter the default timeout for this test Add a call to SUPER^() to your implementation of the FB. Overwrite method Execute() to implement your test Optionally overwrite any of the following methods as desired |Testcase_Base.Setup| |Testcase_Base.Abort| |Testcase_Base.Teardown| InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError , iError ) are present at the outputs for exactly one cycle. ETrigA xAbort BOOL TRUE : Action is stopped immediately and all outputs are reset to their initial values. ETrigA Output xDone BOOL TRUE : Action successfully completed ETrigA xBusy BOOL TRUE : Function block active ETrigA xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrigA xAborted BOOL TRUE : Action aborted by user ETrigA xFinished BOOL Testcase_Base sInfo WSTRING(Constants.WSTRING_LENGTH) additional information (e.g. an error text) Methods: Execute HandleAssertResult HasError Structure: Execute (Method) HandleAssertResult (Method) HasError (Method)
Testcase.Execute (METH) ¶ METHOD PROTECTED Execute : BOOL Overwrite this method to implement the logic of this testcase. Once the test has been started, this method will be called until a) the method returns TRUE , which signals completion of the test, or the test is aborted. Once this method returns TRUE , the output iErrorCode is evaluated: The value 0 signals success, while all other values signal a failure of the test. To provide additional information about the test, set the global output sInfo of the base FB. DO NOT CALL the base implementation of this method SUPER^.Execute() . InOut: Scope Name Type Return Execute BOOL Output iErrorCode INT
Testcase.HandleAssertResult (METH) ¶ METHOD HandleAssertResult : BOOL InOut: Scope Name Type Return HandleAssertResult BOOL Input eAssertion_Result ASSERTION_RESULT wsErrorMsg WSTRING(Constants.WSTRING_LENGTH)