How can I unit test a class which requires a web service call?
- by Chris Cooper
I'm trying to test a class which calls some Hadoop web services. The code is pretty much of the form:
method() {
...use Jersey client to create WebResource...
...make request...
...do something with response...
}
e.g. there is a create directory method, a create folder method etc.
Given that the code is dealing with an external web service that I don't have control over, how can I unit test this? I could try and mock the web service client/responses but that breaks the guideline I've seen a lot recently: "Don't mock objects you don't own". I could set up a dummy web service implementation - would that still constitute a "unit test" or would it then be an integration test? Is it just not possible to unit test at this low a level - how would a TDD practitioner go about this?