Mutation Testing - Mutation Testing Overview

Mutation Testing Overview

Mutation testing is done by selecting a set of mutation operators and then applying them to the source program one at a time for each applicable piece of the source code. The result of applying one mutation operator to the program is called a mutant. If the test suite is able to detect the change (i.e. one of the tests fails), then the mutant is said to be killed.

For example, consider the following C++ code fragment:

if (a && b) { c = 1; } else { c = 0; }

The condition mutation operator would replace && with || and produce the following mutant:

if (a || b) { c = 1; } else { c = 0; }

Now, for the test to kill this mutant, the following condition should be met:

  • Test input data should cause different program states for the mutant and the original program. For example, a test with a = 1 and b = 0 would do this.
  • The value of 'c' should be propagated to the program's output and checked by the test.

Weak mutation testing (or weak mutation coverage) requires that only the first condition is satisfied. Strong mutation testing requires that both conditions are satisfied. Strong mutation is more powerful, since it ensures that the test suite can really catch the problems. Weak mutation is closely related to code coverage methods. It requires much less computing power to ensure that the test suite satisfies weak mutation testing than strong mutation testing.

Read more about this topic:  Mutation Testing

Famous quotes containing the word testing:

    No testing has overtaken you that is not common to everyone. God is faithful, and he will not let you be tested beyond your strength, but with the testing he will also provide the way out so that you may be able to endure it.
    Bible: New Testament, 1 Corinthians 10:13.