Click here to Skip to main content
15,885,757 members
Articles / Programming Languages / Java

Give your tests mutant powers with PIT [Part 1]

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
25 Jun 2015CPOL2 min read 5.8K  
Mutation Testing is amazing. Start doing it with PIT to test your tests. The cost of poor quality is too great to ignore.
 

Mutation Testing basics:  Can your tests survive the coming mutant apocalypse? (LinkedIn)




Mutation testing opens exciting possibilities. Let's start doing it.  Now, stop waiting and just do it.

PIT seems to be regarded as the tool of choice in the Java software development world.  PIT has a maven plugin which can help make it a part of your daily builds.  The tool also works with ant, gradle, and more.  There is even a Sonar plugin available to integrate the mutation testing reports will all your other coverage reports. After you read this post go to the PIT website (http://pitest.org/) and check out all it has to offer.

The cost of entry with the Maven plugin is low but it is not low enough for me,  There is configuration needed to get your project up and running with PIT and the documentation leaves a little be desired. However there is almost no cost to you to install the PIT Eclipse plugin. The plugin that lets you do all the same mutation magic but in eclipse without needing to update your projects pom file and saves you the trouble from running on the command-line. It allows you to limit the tests that are used for mutations very easily.  You can get this going in less than 10 minutes in the morning and be prepared to show it to people at the lunch table.

There are disadvantages to mutation test.  For example it is time consuming and resource intensive.  Which is all the more reason why you should ease into it and put your toes in the water with the eclipse plugin.  It will help you quickly see the value of it.

The plugin can be added via the eclipse market place by searching for the name "PitClipse".  If you need more information about it check out the marketplace website: https://marketplace.eclipse.org/content/pitclipse


The results can be seen in a tree structure in eclipse vs using the html report generated via the command line.

 

 

 

 

 


The html report can also been seen in eclipse but I personally feel the tree view is more usable.

 

 

 

 

 


Don't wait! Install the plugin and get started.  Once you see the mutations that survive from the unit tests you have told yourself are good enough you will be convinced that mutation testing is the way to go.




Give your tests mutant powers with PIT [Part 2]

 

 

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Full stack Java engineer looking to enhance the quality of the code around me. Find out more about me at http://www.bobbylough.com

Comments and Discussions

 
-- There are no messages in this forum --