🔥

Thread (@thewizardlucas)


100% code coverage does not exist. The only way you can make it impossible for your software not to make certain mistakes is with types, not with tests. Here's why 👇

In his brilliant article named "Why Most Unit Testing is Waste" (rbcs-us.com/documents/Why-…) James O'Coplien explains what he'd consider as 100% coverage, and it's different from what most of us think it is:

"I define 100% coverage as having examined all possible combinations of all possible paths through all methods of a class, having reproduced every possible configuration of data bits accessible to those methods, at every machine language instruction along the paths of execution."

"Anything else is a heuristic about which absolutely no formal claim of correctness can be made."

Tests can't prove that your software doesn't have bugs, they can only prove it has bugs. On the other hand, Types allow you to encode certain properties about your programs in advance, in such a way that they can make incorrect states impossible.

In this talk (one of my favourite talks ever), @rtfeldman explains in more detail how to use types to make impossible states impossible: youtube.com/watch?v=IcgmSR…