I'm calling a third party web service right now as part of my application. For this I use RestClient stone. There are a ton of tools available to ensure that it doesn't matter.
I am curious that I have good enough tests, nothing special, I can imitate how my application reacts when a third-party web service is unavailable for any reason. Whether I have exceeded the speed limit or timeout due to latency / network complications, I just want to have something like an HTTP status code and check what my application does in this case.
What is the best way to do this with Test :: Unit? Right now, a call to a third party is encapsulated inside one of my controllers. I have a simple module with some wrapper methods for different endpoints of a remote service. I just want to make sure my application does the right thing when the service is or is unavailable.
Does it use additional infrastructure next to Test :: Unit, which can drown out the correct way to do this? Obviously, I canβt get the network timeout and start hacking things like IPtables for test only, itβs not worth the time. Iβm sure this problem has been solved a million times since integrating things like Facebook and Twitter into web applications is so popular these days. How do you test the error when reaching these APIs in a reliable / controlled format?
source share