How to test API contracts when there is a dependency on data from an outside source
I'm after some advice regarding a project I am currently working on. There is a front-end, similar to what Amazon is like in that sales are fed through the site(there is no API for doing this). However, the requirement I have is to test the microservices that sit behind the UI which go off to various warehouse management systems.
The issue I have is that in order to test each of these services it's dependent on data being passed through from the UI. Obviously it's fine to do this, but each of these tests will take a while to run; what I'm interested in is more of the integration behind each of these micro-services, rather than having to worry too much about the API. Does anyone have any advice about how I could go about this?
Demir last edited by
As long as you can build calls that are in the format the services expect and can manage the authentication the services require, you can test them directly.
What you need to do is work with the developers to get a list of calls and requirements for each service, for example:
- Returns AuthToken
- HasInventory (must send auth token in header)
- Returns true if DesiredQuantity
- ChangeInventory (must send auth token in header)
- Returns true if the operation succeeded.
and so on for each service.
Once you have the list, you can build your calls as if you were working through an API. It will obviously be more complex than this simple example, and you may need to include a lot of extra data, but the general principle remains the same.
Typically, once you have managed to send a successful call, you can easily modify your data to generate different results and test the boundary and error conditions.