Step Functions Local testing with mock configuration provides the capability to mock AWS service integrations that are present in a state machine. This helps in testing the state machine in isolation.
This is sample project which showcases how to run Step Functions local tests with mocks using JUnit and Spock framework instead of running ad-hoc CLI commands. Both type of tests use Testcontainers to run Step Functions Local Docker image.
This is not a replacement of the strategy shown in above blog but another way to test Step Functions state machine with better assertion capabilities. Teams currently using Java for Serverless development can leverage this strategy in their current applications.
- Java 19
- Gradle
- JUnit 5
- Spock Framework
- Testcontainers
- Docker
Make sure docker engine is running before running the tests.
In order to run the tests, just run below gradlew
task from project directory:
./gradlew test
Tests can also be run individually via IntelliJ's native integrations or your choice of an IDE.
Checkout these test classes for details: