Assert functions - Manual - AxUnit - AxUnit - AxUnit,

AxUnit (legacy) CLI Tool (test)

Portfolio
SIMATIC AX
Product
AxUnit
Software version
3.0.4
Edition
08/2025
Language
English (original)
Package Name
@ax/axunit-docs

The decision whether a test fails or not is done and communicated to the test environment by the Assert functions. There are different kind of assert functions for different data types. The Assert functions are in the AxUnit namespace.

Provided Assertions Parameter Supported Type
Equal expected, actual BOOL, INT, SINT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL, LREAL
NotEqual expected, actual BOOL, INT, SINT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL, LREAL
LessThan left, right INT, SINT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL, LREAL
GreaterThan left, right INT, SINT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL, LREAL
{Test(value1 := 1, value2:= 2, exp := 3)}
FUNCTION Adding_Two_Numbers_Returns_The_Sum
    VAR_INPUT
        value1  :INT;
        value2  :INT;
        exp     :INT;
    END_VAR
    VAR_TEMP
        result  :INT;
    END_VAR
    result := ADD(value1, value2);
    AxUnit.Assert.Equal(exp, result);
END_FUNCTION

Warning

Currently we are only supporting a limited amount of failed assert statements for each test. If you run into the problem that not all asserts are covered in the test execution there are several solutions:

  1. Correct or change your code so that the failed asserts are passing.
  2. Write more tests in order to spread out the asserts, ideally one per test!
  3. Use pragmas to test your asserts with different input values.