Define global constants for the testing environment - Manual - AxUnit-ST - AxUnit ST documentation package - AxUnit-ST,

AxUnit-ST CLI Tool (test)

Portfolio
SIMATIC AX
Product
AxUnit-ST
Software version
8.3.9
Edition
07/2025
Language
English (original)
Package Name
@ax/axunitst-docs

You can define a configuration in your lib project to be used exclusively in the tests. This makes it possible to set up a testing-only environment that differs from the productive environment.

  1. Create a file called 'TestConfig.st' in the 'test' folder. The file must not be in a sub folder. This is only necessary in a library, since you can define multiple configurations in an app anyway.
  2. Define a configuration:
CONFIGURATION TestEnvironment
    VAR CONSTANT
        TEST_DEFAULT : INT := 392;
    END_VAR
    VAR_GLOBAL
        RPub : LREAL;
        Service : Service { value := TEST_DEFAULT };
    END_VAR
END_CONFIGURATION
  1. Use it in a test method:
{TestFixture}
CLASS PUBLIC MyTestFixture

    {Test}
    METHOD PUBLIC MyTestMethod
        VAR_EXTERNAL
            RPub : LREAL;
        END_VAR
        AxUnit.Assert.Equal(RPub, 0.0);
    END_METHOD

END_CLASS