Search code examples
unit-testingintegration-testingfunctional-testingfixtures

Integration testing with dependency on outside service


I am currently writing integration/functional tests for my system. Part of the functionality is to hit a web service via http (another system I run).

How should I set up a test instance of the web service to allow for good functional testing? I want to have my system run against this service with live production data.

Should the web service be an independent instance that always has the live production data that I reload manually (maybe reset every time I start an instance of it)?

Should the web service be setup and teared down with every test?

What are some common practices to deal with situations like this?


Solution

  • As first thing please make sure you know difference between Functional Testing and Integration Testing. You can do a pretty good functional tetsing wthout major efforts which are required by integration testing (instantiating web services, accessing a data base). Basically Mocking technique works pretty well even to simulate the Data Layer responses and web service behaviour (I believe such details like HTTP as transport could be ignored for most test cases)

    For such integration testing I would suggest having a separate SIT environment which includes a separate Web service and a Data Base as well.

    Should the web service be an independent instance that always has the live production data that I reload manually (maybe reset every time I start an instance of it)?

    Yep, it should be completely separate but data could be manually generated/prepared. For instance, you can prepare some set of data which allows testing some predefined test cases, this could be test data sets which are deployed to the SIT DB instance before the actual test run and then cleaned up in test TearDown.

    Should the web service be setup and teared down with every test?

    Yep, tests should be isolated one from each other so should not affect each one in any way.