powertools-lambda-java
powertools-lambda-java copied to clipboard
Tech debt: Audit unit tests and replace external dependencies by mocks
Why is this needed?
Currently, some unit tests such as powertools-idempotency-dynamodb depend on running a local server for mocking AWS resources.
This violates the principle that unit tests should run in a self-contained way.
Example which should be avoided:
https://github.com/aws-powertools/powertools-lambda-java/blob/7b18029dff8f86cb9be6be8cbc4567aaacbec418/powertools-idempotency/powertools-idempotency-dynamodb/src/test/java/software/amazon/lambda/powertools/idempotency/persistence/dynamodb/DynamoDBConfig.java#L50-L55
This starts a DynamoDB mock server on localhost.
Which area does this relate to?
Tests
Suggestion
This issues suggests to:
- Audit all unit tests for external dependencies
- Replace external dependencies by self-contained mocking
- Add a test scenario in the end2end tests to cover the use-case using real infrastructure in real AWS accounts
Acknowledgment
- [x] This request meets Powertools for AWS Lambda (Python) Tenets
- [ ] Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, TypeScript, and .NET