3 ms·
Tests - whatever you wish to call them - are an assertion that something will always and forever be true. A unit thus needs to be a unit of code that you are t
by bluGill 3y ago
Tests - whatever you wish to call them - are an assertion that something will always and forever be true. A unit thus needs to be a unit of code that you are telling all future maintainers that they cannot refactor such that this changes.
If you are writing the list data structure for a new language (if you like LISP you are looking for a better name than car/cdr, while C++ guys are thinking vector without the template mess, and ... all are correct for this discussion) - this will quickly be used by everyone and so it doesn't matter if you can't change the API as this data structure will soon be used everywhere in your code and so a change isn't possible. However most classes/functions are only used in a couple places that they are close to and so it isn't a big deal to change them - thus you shouldn't write tests that force the API.
When you have a large system eventually you need to break it up into things that are smaller just to understand. Those are good places to write tests and mocks as you get flexibility internally to do what you want and you don't really understand what is going on outside. However someone needs to write whole system integration tests as nobody understands what happens between the smaller parts.