4 ms·
> When people talk about "unit tests", a unit doesn't refer to the common pattern of "a single class". A unit is a piece of the software with a clear boundary.
by u801e 6y ago
> When people talk about "unit tests", a unit doesn't refer to the common pattern of "a single class". A unit is a piece of the software with a clear boundary. It might be a whole microservice, or a chunk of a monolith that is internally consistent.
Every example I've read pertaining to unit testing uses a function as the unit to test. The easiest functions to test are ones that don't have side-effects (network, I/O, disk, etc). Could you point me to an example where a unit test applies to something beyond a function?
- pydry 6y agoThis bugs me as well. The people who argue about whether unit tests works will often redefine "unit" to mean anything from "the entire application" to a single function. Colloquially, however, anything above the level of a self contained function or class is called something else - typically an integration test.
- UK-Al05 6y agoUnit tests, integration tests were never fully defined that well. They change based on who you talk to. Especially integration tests. Better definition is the small, medium and large tests from Google's testing blog.
- bmh100 6y agoI've used unit tests on attributes and methods of a mock class instance, in order to test the class's construction method.