> Even in the simple example given, there are probably hundreds of different failure cases to account for.
Definitely not hundreds. But yes, they need to be tested
> The successful case is usually the most understood behaviour, most visible, and easiest to recreate.
Tests are not written to document behaviour, but to validate that your program does what it's supposed to do. If you don't test successful cases, you don't even know if it runs correctly.
> If you are going to skimp out on documenting some aspects of your code because you hate future developers, the most understood aspect is where you are best to skimp.
I see you have the erroneous assumption that tests are documentation.
> It is certainly backed up every time I have worked with developers who put no effort into making their code testable, making it way harder than it should be to test certain cases afterwards.
This is slightly orthogonal to being able to write testable code etc. Most tests are trash to begin with, and most testing frameworks give next to zero help in designing and running actual tests you would really want.
I couldn't care less if a team mate wrote "untestable code" in some modules. In 99% of the time that code is some repetitive boilerplate anyway. Ironically, this is the code that everyone prioritises to make testable.
And then you want to test all that in concert... Ahahaha good luck. Even starting up a local rest service with mocked dependencies to test is a royal pain in the butt in most cases, and has nothing to do with testability of some small pieces of code.
> that's what TDD – and, really, testing in general – is all about: Documentation.
Tests are not documentation, have never been, and can never be viewed as such.
Testing is literally about testing: to test that your program behaves correctly given some requirements. It literally is in the name. You write tests not to educate your co-workers, but to make sure your program doesn't crash and burn the moment you push it to prod.
> Nobody advocates writing useless tests. Future readers should be able to learn something useful from every documentation item you write.
Again:
1. Tests are not documentation. Have never been, will never be.
2. Existing testing practices all but enforce writing useless tests, prioritising duplication, hundreds of unit tests etc. over what' actually needed.
> Nobody wants to read documentation that is one big ball of mud.
All tests are inevitably a ball of mud because they lack context, and they are not documentation.