How to test a Twilio application? How to test a Twilio application? ruby ruby

How to test a Twilio application?


(Twilio employee here)

I don't think you have to simulate this one at all. Write a script to actually place calls from your account into the number you want to test. You can even use the Sandbox since your destination number would be a Twilio number and therefore already Verified.

You could have the script call the number (Incoming Call), Say a message to test Recording & Transcription. Since you know the number that it is calling from and to you could use the API to retrieve the specific Call Sids and make sure the Recordings and Transcriptions exist. If you really wanted to get creative, you could make sure the Recording is a certain duration and the Transcription has content.

I wouldn't suggest trying to check specific Transcription content as the engine has been updated a number of times and something breaking because it got better is counter productive.


Do you want to test that your app is interacting with Twilio correctly? i.e. an integration test? Since you have to interact with systems waaay beyond your control (i.e. the telephone system ;-)), this is probably a good place to just write down a manual script. e.g. Do X and Y, enter your phone number, press button labeled "OMG Please Work", if phone rings, the test has passed.

If you want to test that your classes do the right things in response to certain events, then you might want to abstract Twilio behind an neutral API, and then write a test implementation of your API that you can use to drive tests in your code (i.e. unit testing)