Software Testing | Mutation Testing

Mutation Testing is a type of Software Testing that is performed to design new software tests and also evaluate the quality of already existing software tests. Mutation testing is related to modification a program in small ways. It focuses to help the tester develop effective tests or locate weaknesses in the test data used for the program.

History of Mutation Testing:
Richard Lipton proposed the mutation testing in 1971 for the first time. Although high cost reduced the use of mutation testing but now it is widely used for languages such as Java and XML.







Mutation Testing is a White Box Testing.

Mutation testing can be applied to design models, specifications, databases, tests, and XML. It is a structural testing technique, which uses the structure of the code to guide the testing process. It can be described as the process of rewriting the source code in small ways in order to remove the redundancies in the source code.

Objective of Mutation Testing:
The objective of mutation testing is:

  • To identify pieces of code that are not tested properly.
  • To identify hidden defects that can’t be detected using other testing methods.
  • To discover new kinds of errors or bugs.
  • To calculate the mutation score.
  • To study error propagation and state infection in the program.
  • To assess the quality of the test cases.

Types of Mutation Testing:
Mutation testing is basically of 3 types:

  1. Value Mutations:
    In this type of testing the values are changed to detect errors in the program. Basically a small value is changed to a larger value or a larger value is changed to a smaller value. In this testing basically constants are changed.

    Example:

    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; 
  2. Decision Mutations:
    In decisions mutations are logical or arithmetic operators are changed to detect errors in the program.

    Example:

    Initial Code:
    
    if(a < b)
     c = 10;
    else
     c = 20;
    
    Changed Code:
    
    if(a > b)
     c = 10;
    else
     c = 20; 
  3. Statement Mutations:
    In statement mutations a statement is deleted or it is replaces by some other statement.

    Example:

    Initial Code:
    
    if(a < b)
     c = 10;
    else
     c = 20;
    
    Changed Code:
    
    if(a < b)
     d = 10;
    else
     d = 20; 

Advantages of Mutation Testing:

  • It brings a good level of error detection in the program.
  • It discovers ambiguities in the source code.

Disadvantages of Mutation Testing:

  • It is highly costly and time-consuming.
  • It is not able for Black Box Testing.


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.