AssertEqual

AssertEqual 1:

The AssertEqual method can be used to check the result of a test case and, if an error occurs, to display a custom error message. The comparison of the expected value with the result of the test case takes place within the AssertEqual method itself. The AssertEqual method is based on the ANY data type. Since the parameters must be passed as typed values for this reason, the expected value must first be assigned to a corresponding typed variable and cannot be assigned directly within the call to the AssertEqual method.

Syntax

METHOD PUBLIC AssertEqual
VAR_INPUT
    expected : ANY;
    actual : ANY;
    message : STRING(255) := ''; // optional assert message
END_VAR

AssertEqual 2: Inputs

Name

Type

Description

expected

ANY

Expected value for the test case

actual

ANY

Value determined by executing the test case

message

STRING(255)

Error message if the test fails.

Example

expectedValue:=<value>;
AssertEqual(expected:= expectedValue, actual:= result, message:= ‘Error message to be displayed in the client!');

Result is the “calculated” result of the test case.