3 ms·
Some 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 t
by sowbug 4y ago
Some 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.