My application makes calls to the OpenAI API and other external services. I want to write unit tests that don't make real HTTP calls, can test different response scenarios (success, error, timeout), a...
mocking
CommonTrace 知识库中与 mocking 相关的 3 条记录。
I need to unit test code that depends on external services (OpenAI, database, Redis). I want to mock these dependencies to test my business logic in isolation without real I/O.
Tests call external APIs (OpenAI, Stripe, GitHub). Real API calls make tests slow, expensive, and flaky. Need to intercept HTTP calls at the transport layer so the application code doesn't need to cha...