1

If we would mock each DynamoDB API call separately in our unit tests, it would be very tedious to write all the expected calls and return values in these mocks. And when we change something in the database structure, many of these mocks would need refactoring.

More efficient would be to mock DynamoDB by a 2 level deep nested HashMap, storing the data that's stored by the unit tests, and returning these data when appropriate. The work is in writing the DynamoDB API methods in this mock that are called by our software under test. However, as we use only a small subset of the DynamoDB API, that's less work than writing all above mentioned expects.

(A system like LocalStack would be much slower in the develop - test - fix cycle, we need something as fast as a conventional unit test with mocks.)

I've searched for such a deep mock that's already written and open sourced, but I couldn't find one. Does anybody know such a deep mock for the DynamoDB Java API?

1 Answers1

1

You can try DynamoDB local. It allows you to use the DynamoDB API.

Here is a past posts that can help.