2 ms·
I thought of a good way to break down why obsession with code coverage is poor. The same program can be represented in many different ways. And code is data.
by kazinator 2y ago
I thought of a good way to break down why obsession with code coverage is poor.
The same program can be represented in many different ways. And code is data.
We can take the program and compile it to a byte code. We then represent the byte code as an array of bytes which is bundled with the virtual machine to make the working program.
The byte code uses every instruction of the virtual machine. And so, wee, we have 100% code coverage.
Of course not 100% of the byte code array is executed by the VM, but pay no attention to that. Code coverage is about code, not data!
The only coverage that matters is the coverage of the state space: hitting all the cases that can occur. There isn't a nice one-to-one correspondence between control flow paths and cases. A routine which adds to unsigned 16-bit integers has 65536 x 65536 cases, but nowhere near that many paths through its control graph.