Documented unittests & code coverage

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 4 03:24:39 PDT 2016


On 8/4/2016 1:13 AM, Atila Neves wrote:
> On Thursday, 28 July 2016 at 23:14:42 UTC, Walter Bright wrote:
>> On 7/28/2016 3:15 AM, Johannes Pfau wrote:
>>> And as a philosophical question: Is code coverage in unittests even a
>>> meaningful measurement?
>>
>> Yes. I've read all the arguments against code coverage testing. But in my
>> usage of it for 30 years, it has been a dramatic and unqualified success in
>> improving the reliability of shipping code.
>
> Have you read this?
>
> http://www.linozemtseva.com/research/2014/icse/coverage/

I've seen the reddit discussion of it. I don't really understand from reading 
the paper how they arrived at their test suites, but I suspect that may have a 
lot to do with the poor correlations they produced.

Unittests have uncovered lots of bugs for me, and code that was unittested had 
far, far fewer bugs showing up after release. The bugs that did turn up tended 
to be based on misunderstandings of the requirements.

For example, the Warp project was fully unittested from the ground up. I 
attribute that as the reason for the remarkably short development time for it 
and the near complete absence of bugs in the shipped product.

Unittests also enabled fearless rejiggering of the data structures trying to 
make Warp run faster. Not-unittested code tends to stick with the first design 
out of fear.


More information about the Digitalmars-d mailing list