HomeTesting Concepts

What is Mutation Testing?

What is Mutation Testing?

<<Previous Post                              << Complete Tutorial>>                                 Next Post>>

What is Mutation Testing?

Mutation Testing is a white box testing technique in which the application source code is mutated(changed) in small ways, to verify whether the executed test cases are resulting in bugs after mutation.  The purpose of Mutation Testing is to check the quality of the test cases, by verifying that the faulty/mutant code is failing the test cases. As a result of mutation testing, the ambiguities in the code which cause the system to fail will be identified and fixed. The following are the steps involved in Mutation Testing:

 

  1. Test cases will be executed against the Non-Mutated/Original source code of the Application to check the passing of Test cases.
  2. Extremely small mutated/faulty code will be introduced into the Application source code
  3. Test cases will be executed against the Mutated/faulty source code of the Application to check the failing of Test cases.
  4. The output of the Test cases executed in step 1 (Original Source) and step 2 (Mutated Source code) will be compared
  5. If the output of the Test cases executed against original and mutated source codes are different, then the Test cases are considered as effective and the mutation introduced into the source code will be killed.
  6. But if the output of the Test cases executed against original and mutated source code is same, then more effective test cases will be created for identifying these unidentifiable defects in the code and the mutation will be kept alive.

 

Example for Mutation Testing: The following is an example for Mutation Testing where the mutation has been introduced into the original source code by replacing the > symbol with < symbol. When the test cases against the original and mutated code are executed, Test cases should pass when executed against original source code and fail when executed against the mutated source code.

 

Original Source Code
Mutated Source Code
if(a>b)
   print “a is greater than b”
else
  print “b is greater than a”
       if(a<b)
          print “a is greater than b”
       else
          print “b is greater than a”

 

Types of Mutation Testing: Based on the type of mutation introduced into the code, Mutation Testing can be classified into the following types:

 

  • > Value Mutations: Mutation will be introduced into the code by changing the values in the code, with an intention of finding the errors in the code. Example: Values in the code will be changed to much smaller values or much larger values.
  • > Decision Mutations: Mutations will be introduced into the code by changing the Decisions/conditions with an intention of finding the errors in the code. Example: Relational operators / Logical operators will be mutated.
  • > Statement Mutations: Mutations will be introduced into the code by deleting the statements or duplicating them with an intention of finding the errors in the code.

 

Mutation Testing Tools: The following are the different tools which can be used for automating the Mutation Testing:
  • > Ninja Turtles – A .net mutation tool
  • > Mutagenesis – A PHP mutation testing framework
  • > Jester – A Java mutation tool
  • > Pester – A Python mutation tool
  • > MuClipse for eclipse.

 

More details on Mutation Testing: The below are few points, which help you in understanding Mutation Testing in detail:
  • > Also known as Fault-based Testing, as the mutants/faulty code will be introduced into the code with an intention of finding ambiguities in the code and creating effective test cases.
  • > Mutation Testing is a white box testing technique.
  • > Mutation Score = (Killed Mutants/Total Mutants)*100  – Test cases are mutant ready when this score reaches 100%
  • > Mutation Testing is an approach to attain high coverage of the application source code.
  • > Error finding is high in this approach, as a result, the developer will end up in developing most reliable and stable system.
  • > Mutation testing is costly and time-consuming, as a result, a subset of mutants will be used for testing in a random manner.

 

Conclusion: Mutation Testing is a white box testing technique in which the application code is mutated with a faulty code with an intention of finding the effectiveness of the tests and also finding the ambiguities in the code which cause the system to fail.

Next Steps:

  • > To learn more about Software Testing, continue to the next post (Click on the Next Post link below)
  • > Check complete Software Testing Tutorial Contents here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning ?

About Me > Arun Motoori

<<Previous Post                              << Complete Tutorial>>                                 Next Post>>

On a mission to help the Software Testing Community in all possible ways.

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp