What's the purpose? - Manual - AxUnit-ST - AxUnit ST documentation package - AxUnit-ST,

AxUnit-ST CLI Tool (test)

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

The main purpose of using mocks is to create predictable test environments by isolating the unit being tested from its external dependencies. By doing so, you can focus on testing the specific logic or behavior of the unit without worrying about the actual implementation details of its collaborators.

When writing unit tests, you can replace real objects with mocks. Therefore, you have to use the technique of Dependency Injection. It enables you to exchange the concrete implementation of an object with a stub. A stub acts as a small piece of code that replaces another component during testing.

This enables you to simulate various scenarios, such as error conditions, exceptional cases, or specific data sets, and observe how the unit under test behaves and interacts with its dependencies.