powertools-lambda-java icon indicating copy to clipboard operation
powertools-lambda-java copied to clipboard

Tech debt: Audit unit tests and replace external dependencies by mocks

Open phipag opened this issue 5 months ago • 0 comments

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:

  1. Audit all unit tests for external dependencies
  2. Replace external dependencies by self-contained mocking
  3. Add a test scenario in the end2end tests to cover the use-case using real infrastructure in real AWS accounts

Acknowledgment

phipag avatar Jul 11 '25 09:07 phipag