In more complex situations, good tests also show you the environmental set up - for example, all the various odd database records the code needs or expects.
It’s not everything you’d want out of a doc, but it’s a chunk of it.
In more complex situations, good tests also show you the environmental set up - for example, all the various odd database records the code needs or expects.
It’s not everything you’d want out of a doc, but it’s a chunk of it.
If you can't find examples of how to use the code in the code then why does the code even exist?
1. The code uses internal interfaces, not meant to be used by users of the code.
2. The code might not use the high level public interfaces you are interested in. Those interfaces are meant to be used by users, and tested by tests.
Having said that reading the code itself is often fruitful. Not for example usages, but to just learn how the thing is implemented.
New rule: if you write a function, you also have to write down what it does, and why. Deal?