3 ms·
I'll mirror a sibling comment. For me your mentality is the rookie mentality. I too once believed in strict unit tests, as well as a strict differentiation bet
by BeetleB 3y ago
I'll mirror a sibling comment. For me your mentality is the rookie mentality. I too once believed in strict unit tests, as well as a strict differentiation between them and other kinds of tests (end to end, integration, etc).
Then I joined a project where they were just starting to add tests to an existing project, and the lead developer was adamant on the following philosophy: "Virtually all tests will run the full program, and we'll mock out whatever slows the tests down (e.g. network access, etc)". I whined but I had to comply. After a year of this, I give him credit for changing my mindset. The majority of bugs we found simply would not have been found with unit tests. On the flip side, almost none of the unit test failures were false alarms (function signature changed, etc).
Since then, I've dropped categorizing tests as unit tests vs other types of tests. Examine the project at hand, and write automated tests - preferably fast ones. Focus on testing features, and not functions.