2 ms·
I would argue that this type of code in most cases isn't a good candidate for unit testing. Typically, dependency-heavy code is better tested via integration t
by j_baker 17y ago
I would argue that this type of code in most cases isn't a good candidate for unit testing. Typically, dependency-heavy code is better tested via integration tests.
The problem with mocking that I've run into is that you're not really testing expected functionality. You're testing that code calls an API. This sounds good in theory until you need to change the API. Then, you have a whole bunch of tests to clean up.
- brown9-2 17y agoI prefer to think of it as testing how you code behaves when the API returns x, y, or z. It can be a pain to change the mocks and tests when the API changes, but what else can you do - not test this layer of your code?
- j_baker 17y agoJust because you don't unit test something doesn't mean you can't test it. This is what integration tests exist for.