You've built your Lambda. You've deployed it. But are you scared to touch it? Do you make a small change and then anxiously click the test button hoping you didn't break anything?
Today, we're building a safety net with unit tests and integration tests.
We'll use the testing pyramid as our framework, starting with unit tests that run in milliseconds using Moto to mock AWS services like DynamoDB - no credentials needed, no costs incurred. We'll cover the lazy initialization pattern that makes Lambda functions testable. Then we'll move up to integration testing with CDK watch for rapid feedback against real AWS services.
We'll make mistakes along the way so we understand not just what to do but why we do it this way.
Source code: https://github.com/prime-computing-la...
References:
Moto - Mock AWS Services: https://docs.getmoto.org/en/latest/
Pytest: https://docs.pytest.org/
CDK Watch: https://docs.aws.amazon.com/cdk/v2/gu...
Lambda Testing Best Practices: https://docs.aws.amazon.com/lambda/la...