Use mutation testing to benchmark unit test quality
Traditional test coverage (i.e line, statement, branch, etc.) measures what code is executed by your tests. It does not check that your tests are actually able to detect faults in the executed code.
Mutation testing fills this gap. Faults (or mutations) are seeded into your code, then your tests are run. If your tests fail then the mutation is killed, if your tests pass then the mutation lived. The quality of your tests can be gauged from the percentage of mutations killed.
/* Initial code */
int mod = 1000000007;
int a = 12345678;
int b = 98765432;
int c = (a + b) % mod;
/* Changed code */
int mod = 1007;
int a = 12345678;
int b = 98765432;
int c = (a + b) % mod;
/* Initial code */
if (a < b) {
c = 10;
} else {
c = 20;
}
/* Changed code */
if (a > b) {
c = 10;
} else {
c = 20;
}
/* Initial code */
if (a < b) {
c = 10;
} else {
c = 20;
}
/* Changed code */
if (a < b) {
d = 10;
} else {
d = 20;
}