3 ms·
Or just, y'know, write a brief comment. Testing is one of those places where the function name occurs exactly once, perhaps twice if the language doesn't have
by klyrs 4y ago
Or just, y'know, write a brief comment. Testing is one of those places where the function name occurs exactly once, perhaps twice if the language doesn't have a nice testing framework. It doesn't need to be self-documenting.
- sowbug 4y agoSome assert functions take an optional string that's printed to stderr or stdout when the condition fails. I've found that a more useful place to put the text that would go into a comment, because you can see the presumed "why" of the failure without looking at the source. This information could go into the test function name, but you can be much more verbose in the freeform text. And it's guaranteed to move along with the assertion during a refactor, unlike comments that can get separated from the code.