3 ms·
I recently went to the effort of trying to work out where the term unit test came from in some desperate effort to find what a unit was meant to be. After much
by __alexs 4y ago
I recently went to the effort of trying to work out where the term unit test came from in some desperate effort to find what a unit was meant to be.
After much googling and buying or ancient text books I hit a dead end. At this point I think "unit" is just noise that confuses people into making distinctions that don't exist.
- switchbak 4y agoAs I recall the TDD mailing list has some background on the use of the word "unit", it goes WAY back, I believe it goes back to the mainframe/ punch card era. Regardless, I think it roughly translates to C's notion of the unit of compilation. Which is obviously not what people really mean these days, but the phrase stuck. The early Xp'ers even found it an issue back then. For a while people tried to push the term "micro tests", but that didn't really take off. I agree with Gerard Mezaros and Martin Fowler and typically follow their (very mainstream) definitions on this stuff. Integration and functional testing have their own ambiguities too, it's definitely a frustrating situation to not have solidly defined foundational terms.
- Izkata 4y agoIIRC the "unit" in "unit test" was meant to mean "semantic unit" ("the access module", for example, should be distinct with a well-defined interface that all the tests go through), but very quickly turned into "syntactic units" ("a single function", for example, where the "well-defined interface" ends up just being function arguments/return value) because most people didn't understand what the original proponents meant.
- branko_d 4y agoI have a Web API which calls a DB API which calls a stored procedure which executes several SQL statements. The Web API has a well-defined and documented interface. Is it a “unit”?
- Izkata 4y agoIn the semantic sense? No, or at least probably not if that's where you jump to. You're still thinking in terms of syntax. Think in terms of business rules, not the code structure: What's one thing your API does?
- oskrim 4y agoSee "Software Engineering at Google" https://abseil.io/resources/swe-book/html/ch11.html https://abseil.io/resources/swe-book/html/ch11.html, the definition of a "small test". This is roughly my definition of unit test: "tests run in a single process"