Most of the logic for my webservice involves talking to our supplier's webservices (checking availability, ordering etc.) They don't have a test environment and the majority of calls can't be run arbitrarily (for example a cease would be run once and would actually stop a service).

Is it feasible to run unit tests in this environment? I could simulate typical responses but I'm worried that hardcoding supplier responses would undermine the point of unit tests.

3 Answers 3


No, it won't. The point of unit tests is precisely to test your code in isolation, independent of the external world.

Testing your whole system interacting with external parties like web services etc. is integration/system testing. This is also needed in most to all real world projects, but it is a different level than unit tests. Actually it sounds like in your situation, since you have difficulties in integration testing, you need unit tests even more than usual.

As a long term goal, you may consider educating and/or pestering said suppliers to set up a test environment for themselves and their clients. You may need to invoke your management's support for this to succeed though, so get prepared with hard facts and figures to convince them about the business value of a test environment.

  • 12
    +1: "you need unit tests even more than usual". And you need to accurately mock the supplier request/response, timeout, error, bad credentials and all the other little things that cause "problems" in an application like this.
    – S.Lott
    Sep 9, 2011 at 10:26

Unit testing will also provide you with an unambiguous, executable specification of the behavior you expect from your suppliers. This will probably make communicating with them much easier.

If there is some problem in the interaction between your and theirs, you can provide them with your unit tests to clearly state what behavior your code expects. If their code does not behavior the same way your unit tests do, the differences are usually easy to spot.

  • Such tests are indeed useful, but the widely used terminology for these is system / acceptance tests rather than unit tests. Sep 9, 2011 at 12:28
  • @Josh Peterson I have had complaints from their "developers" before because I just sent them xml rather than explaing the xml content. I think unit tests wouldent get me very far :) Sep 9, 2011 at 16:43


This is really an Return On Investment question. Do you feel that investing in unit tests is worth what you will get back. Namely, your code tested in isolation. As well as all the other benefits of unit testing.

You can contrast this with say an automated acceptance test approach where you would get a test account from your supplier actually test the integrated system with the tests. Is the cost of doing ATDD worth what you get back. Namely, testing of the system as a whole.

It's up to you to do the analysis and figure if you should do unit testing, automated acceptance testing, both, neither, or something else.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .