Search code examples
javatestingintegration-testing

Simulate external webservice for integration test


I have to simulate external webservice, specially SOAP webservice, to run integration test in java.

Any suggestion?


Solution

  • There are two approaches to this:

    1. Run your integrations tests against the real external webservice, or a test version of it.

    2. Write your own test webservice that simulates the subset of the external service's behavior required for your integration tests.

    Note that depending on the nature of the service you are trying to simulate, your test service could be pretty dumb; e.g. providing pre-computed / hard-wired responses to expected requests.


    There is no magic here. Just common sense and hard work.