Parameterized tests - 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

While writing tests, it is often necessary to run the same test code with different parameters multiple times. This is simplified by AxUnit's pragma notation. In this notation syntax, the test-run parameter can be defined. They will be passed to the test function during execution. The following examples demonstrate how to parameterize tests using pragmas.

Note

Currently only elementary data types are supported.

{Test(value := 1)}
{Test(value := 2)}
{Test(value := 32767)}
FUNCTION The_add_of_positive_value_to_max_int_returns_negative_value
    VAR_INPUT
        value:INT;
    END_VAR
    // some test code
END_FUNCTION
{Test(value1 := 1, value2:= 2)}
{Test(10, 20)}
FUNCTION Adding_Two_Numbers_Returns_The_Sum
    VAR_INPUT
        value1:INT;
        value2:INT;
    END_VAR
    // some test code
END_FUNCTION

Warning

  • Parameters are provided in the VAR_INPUT section of the test-function.
  • Every parameter must be assigned in the pragma in case parameters are specified.
  • Casing and ordering is not relevant if named parameters are used.
  • Currently only elementary data types are supported.