You think customers aren't affected if you mistakenly replace a < with a <= in your code?
while (car.wheels < 4)
car.attach(new Wheel);
Re:99% code coverage (2017)
by nathan_f77 on Wednesday January 16, 2019 @07:13AM
(#18920143)
'<' versus '<=' can be very important, and it can cause severe bugs when dealing with things like array indices or financial data.
There are some cases where it's not a big deal. '<' and '<=' can be interchangeable if one or both of the values are a rough estimate. One example would be comparing two images and doing something if they are a close match. It might not be too bad if you use `<= 0.995` instead of `< 0.995` when checking the percentage.
Some other examples might involve accelerometer data, pressure sensors, GPS boundaries, debounce algorithms, animations, etc. But I think it's just a good habit to write test cases that test those boundary values.
Basically, it depends on whether we're dealing with floats or integers.
Re:99% code coverage (2017)
by rachelmcarmena on Wednesday January 16, 2019 @06:23PM
(#18926612)
Thanks for the feedback. The post only answers "Do we have a good safety net to change this legacy code?".
Mutation testing is not a new concept. It's usually used in critical systems: the system is mutated and you measure the time for detecting the mutation and the time for solving the problem.
I think this might apply when you write your own algorithms and want to test them. But if you are, like most of us, working on Business Logic, then you are probably writing the wrong tests.
We usually want to know whether a workflow or a customer story works as intended and as such we should write more Integration tests.
The idea itself has merit though and draws parallels to writing tests with variable or random input parameters, I am pretty sure there already was something on this.