Hacker News new | ask | show | jobs
by metaphorm 3185 days ago
you're already writing the test cases to ensure correct behavior with typical input, and predictable exceptional input. putting in one more assert for predictable exceptional input (wrong type) doesn't really add a noticeable amount of overhead to writing the tests you were already writing.
1 comments

>putting in one more assert for predictable exceptional input (wrong type) doesn't really add a noticeable amount of overhead

Yes. We call that 'typing'.

And it takes less typing (keyboard) than the assert, and you get free documentation inline with the code!