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.
- 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.
- 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
- 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