Download the latest pitest and pitest-ant jars and put them somewhere convenient.
First define the PIT task within your build
<taskdef name="pitest" classname="org.pitest.ant.PitestTask" classpathref="pit.path" />
The referenced classpath should include both pitest.jar and pitest-ant.jar along with any plugins you wish to use. The test library (i.e JUnit or TestNG) must currently also be referenced here as well as on your compilation classpath. This requirement will hopefully be removed in a future release.
Next create a target
<target name="mutationCoverage"> <pitest pitClasspath="pit.path" classPath="mutation.path" targetClasses="com.yourcodebase.*" targetTests="com.yourcodebase.*" reportDir="pathToWhereYouWantOutput" sourceDir="pathToYourSource"/> </target>
Two separate classpaths need to be supplied - pitClasspath should contain to the pitest jars and plugins (plus test library), classPath should contain the classpath used when normally running your unit tests (including the test library).
The two classpaths are kept separate so no conflict should occur if you use a plugin that depends upon a conflicting version of a library used by your code.
The classPath parameter is used to supply PIT with the classpath to for examine tests and code to mutate, and for all dependencies required in order to run the tests.
PIT will accept a path defined using any of the standard Ant mechansims.
Note - by default PIT will not mutate code within jar files or directories called test-classes or test-bin. If this is not the desired behaviour please refer to the general configuration options that PIT supports.
PIT supports a number of configuration options, their behaviour is identical to that described in Command line quick start. The names of these options map to parameters on the ant task.
To help people evaluate PIT an example project using ant is provided at pit ant example
To try it out checkout the source
git clone https://github.com/hcoles/pitest-ant-example.git
then run the pit target
Mutation testing should complete in 10 to 20 seconds (most of which is PIT waiting to decide if it has encountered an infinite loop), then results should be written in html to the pitReports folder.