I'm seeking for advice on properly unit testing a REST client.
I'm working on a client library which is going to be a wrapper (driver) around an online service's REST API, and I'm at the point of writing unit tests, and while reading through tutorials and Googling around for an hour or so on this question, I couldn't find an answer to my question:
- Should I write unit tests by mocking the return values with the test framework?
- Should I put an HTTP mock server into my Travis CI config and execute the requests against that? (not sure if this is possible but I expect it to work)
- Should I execute my unit tests against the actual real-world service using a functional account?
The last one seems to be a potential pitfall/bad practice to me but on the other hand, it does give me lots of guarantees, because I don't introduce an extra layer into my code, functions would be guaranteed to receive real-world responses and it does actually save me lots of time for me.
This is going to be an open source product, no enterprise-grade requirements, and the external service's SLA is high.
In case all three approaches would be acceptable, which one would you go for and why?
Aucun commentaire:
Enregistrer un commentaire