4 ms·
but suppose that service could give all sorts of different responses, depending on (say) the time of day and the country originating the request.
by zabzonk 3y ago
but suppose that service could give all sorts of different responses, depending on (say) the time of day and the country originating the request.
- pyrale 3y agoWhat's relevant to you is your element under test, not the dependency. Does the component you're testing have a different behaviour for each different response? If yes, you're out of luck (but also, maybe you should split it in multiple components). If not, then you probably don't need to test every possible response the dependency returns.
- 8n4vidtmkvmk 3y agoYou're not out of luck. Your testing framework should allow you to hardcode different responses to different requests. Include the time in the response if you need to, it shouldn't be hard. I've started adding random elements to my mock responses to force other developers to not assert things that aren't relevant to the test.