I was thinking about unit tests and code coverage, and I came up with this thought:
It is possible to have 100% code coverage and not test 100% of your code.
For example:
function myTestedFunction(){
doSomething();
doSomethingElse();
}
In this example, if I have a test that myTestedFunction
calls doSomething
, doSomethingElse();
will count as tested, even though it’s not. Is there some way or library that will run your tests with each line removed? I feel like I’m describing it poorly.
I’m using Node.js at the moment, but I’m more curious if something like this exists.
So does anybody know of such a thing?
Thanks!
3
What you’re talking about is called mutation testing, and there are a number of implementations available. I’ve not tried either, but there are at least two javascript versions:
- grunt-mutation-testing, and
- mutandis
2