overview
theTestRunner
class is responsible for executing tests by managing the test server, making calls, and collecting results. it coordinates the entire testing process.
constructor
parameters
port
(int): the port to run the test server onngrok_url
(str): the ngrok url for external access to the test servertwilio_phone_number
(str): the phone number to use as the “from” number for outbound test callsevaluator
(BaseEvaluator | None, optional): the evaluator to use for assessing test results. defaults to none.
constants
INBOUND
: Constant for inbound call typeOUTBOUND
: Constant for outbound call type
methods
add_test()
adds a test to the test runner.
run_tests()
runs all added tests and returns the results.
parameters
phone_number
(str): the phone number to call or receive calls fromtype
(str, optional): the type of calls to make (INBOUND or OUTBOUND). defaults to OUTBOUND.
returns
- List[TestResult]: the results of all executed tests
example usage
features
- manages a fastapi server for handling calls
- coordinates with twilio for making/receiving calls
- executes multiple tests in parallel
- collects and evaluates test results
- supports both inbound and outbound testing
notes
- requires environment variables for various api keys (twilio, openai, etc.)
- uses ngrok for exposing the local server to the internet
- can run multiple tests simultaneously
- supports different types of evaluators (local/cloud)
- handles test execution, result collection, and cleanup