samedi 16 septembre 2017

Integration Testing: Testing service to service

This question might be more suited to the software engineering stack exchange so please move it if that's the case.

I'm looking for some advice on testing strategies for service to service communication.

I have one service (service A) that makes a call to another service (B) - which is a rest API. Both services are owned by me.

I have some unit tests around the service calls and I simply mock the http library so no requests are actually sent to the service. That works well for unit testing but I was wondering if it is worthwhile to add some integration tests that actual test the service calls and responses.

The problem I see is service B updates a database so any integration tests in service A will have to reset any changes they make by calling the DB directly. To me this doesn't seem ideal as now service A knows more about the implementation of service B than it should.

Are these tests valuable? When I've seen these kind of tests before they are often brittle and rely on development environments being in a good state. If this was a third party API for example I wouldn't have tests which call it directly.

I can think of two options:

1). Write the integration tests in service A and have these tests call service B's database to reset/inset data as needed.

2). Stick with mocks and don't add integration tests to service A. Instead add some functional tests to service B which test the various rest endpoints.

Any advice or thoughts?

Thanks

Aucun commentaire:

Enregistrer un commentaire