News for hackers. Stuff that matters.
Re:Unit Tests as Documentation by bluefirebrand on Thursday October 17, 2024 @08:11PM (#41875127)
> good tests show you how to use the code

If you can't find examples of how to use the code in the code then why does the code even exist?

Re:Unit Tests as Documentation by esafak on Thursday October 17, 2024 @10:58PM (#41875986)
Code is not always meant to be run by strangers, if it's internal to a team. The interface for customers should be documented.
Re:Unit Tests as Documentation by badmintonbaseba on Friday October 18, 2024 @06:19AM (#41877941)
There are multiple problems with that:

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.