Strategies to block an external webservice to simulate “down” during for a testing scenario?

StackOverflow https://stackoverflow.com/questions/1787006

문제

I am working to integrate data from an external web service in the client side of my appliction. Someone asked me to test the condition when the service is unavailable or down. Anyone have any tips on how to block this site temporarily while we run the test to see how the service degrades?

For those curious we are testing against Virtual Earth, but Google Maps but this would apply to any equally complicated external service.

any thoughts and suggestions are welcome

도움이 되었습니까?

해결책

You need to be sure to test the most common failure modes for this:

  1. DNS lookup fails
  2. IP connection fails (once DNS lookup succeeds)
  3. HTTP response other than 200
  4. HTTP response incomplete or timeout
  5. HTTP response 200 but RPC or document returned is invalid

Those are just a few common failure modes I could think of that will all manifest themselves with different behaviors that you may wish to have your application handle explicitly.

If you set up a computer between the caller and service that routes between them, you can simulate each of these failure modes distinctly and modify your application to handle them.

다른 팁

Create some Mock-Webservice class or interface (and inject it). In there, you could test the response of your system to webservice failures and also what happens, if a web-service request take longer than expected or actually time-out.

DeveloperWorks article on mock testing: http://www.ibm.com/developerworks/library/j-mocktest.html

How about blocking the domain name(s) in question by putting a nonsense entry into the hosts file?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top