3 ms·
"Unit tests are unlikely to test more than one trillionth of the functionality of any given method in a reasonable testing cycle." Taken literally, sure. But a
by al2o3cr 13y ago
"Unit tests are unlikely to test more than one trillionth of the functionality of any given method in a reasonable testing cycle."
Taken literally, sure. But are you seriously implying that it's useful, or even sensible, to write test cases for every possible input to the line "z = x + y"?
(previous HN article on testing floating-point implementation details notwithstanding)
- michaelfeathers 13y agoUnit tests are a tool for understanding. Their value does not come from targeting coverage and formal correctness. At the end of the day, we have to convince ourselves that our code works. We can do that by looking at it and seeing what it does, and by writing tests to demonstrate that we are not lying to ourselves about what we've reasoned. Write tests for things that you are curious about or don't understand - those are thing things that need to be tested.
- davidw 13y agoUsing something like QuickCheck, you can generate a lot of different input for one function, including edge cases and everything in between.