I post links and comments to interesting things on the internet. Sometimes I write stuff.

The goal of your testing strategy

The key here isn’t that you are trying to look at things in isolation, the key is that you are trying to isolate things that are preventing you from getting quick feedback on the state of the system.

We usually repeat some things without stopping to think about them in detail. We like to say that Unit Tests are supposed to test small "units" of the system in isolation, and we take for granted that we should mock anything that looks like an external dependency. But sometimes we end up, basically, testing mocks, because we focus so much on the "unit" internals that we forgot to test its significant interactions with other components.

The key issue with unit testing the system as a set of individually separated components is that concept that there is value in each component independently. There isn’t. The whole is greater than the sum of its parts is very much in play here.

I'd say there is a lesson here (at least for myself): stop mocking all the things just because they are "external" dependencies. Take a look at the overall logic and interactions, create tests that can verify the requirements, and start mocking whatever gets in the way of obtaining quick feedback.

Hi, I'm Alejo Figueroa. I write code to create websites, APIs and services.

See more notes like thisGo to main page