DEV Community

Discussion on: #Discuss - API Level Functional / Integration Tests in a Microservices Architecture

Collapse
 
alexanderjersem profile image
AlexanderJersem

I think you can use a combination of these methods. On each PR, you can spawn an instance of the service under test plus all the required data structures like the database. The services that the service under test depends on should be mocked. This approach will allow you to test each service in isolation and detect problems earlier. Additionally, you can have contract testing to detect breaking changes, and a failure on these tests would block the merge of the PR until it's fixed. After a successful merge, you can have an integration test environment where all services are running and run the tests there. Regarding data fixtures on the integration test environment, you can consider having a common set of data that should be compatible with all the services.