DEV Community

loading...

Discussion on: 100% test coverage is not enough...

Collapse
nickholmesde profile image
Nick Holmes

Unit Tests (100% or otherwise) are not an appropriate tool for assessing the design of your code.

Could be 100% Code Coverage, properly modularized & SOLID, and still have a blatant bug in it;

Here's some code:

public string foo(bool a, bool b)
{
    string x = "Hello World";

    if(a)
        x = null;

    if(b)
        x = x.ToUpper();

    return x;
}

and here are the tests for 100% code coverage:

Assert.AreSame("Hello World", target.foo(false, false));
Assert.AreSame(null, target.foo(true, false));
Assert.AreSame("HELLO WORLD", target.foo(true, true));
Collapse
mburszley profile image
Maximilian Burszley

"Blatant bug" or intentionally sabotaged?