Jenkins : Using Testability Explorer in Maven 2 projects

Explains a temporary solution how to use the Testability Explorer in Maven 2 projects. 


Testability Explorer is an open-source tool that identifies hard-to-test Java code. Right now, you can run the program from the Command Line or using the Ant Task. There is no Maven 2 plugin available at the moment. You have to use the maven-antrun-plugin for the time being. However, there is one big problem. The Testability Explorer JAR files are not available yet in any Maven 2 repository. This page offers a temporary solution for this problem until the JAR files become available in any public Maven 2 repository.

Installing the JAR files to local Maven repo

In order to use the maven-antrun-plugin with the, you have to add two dependencies into your Maven 2 pom.xml under the dependencies section.



As said before, the JAR files are not available in any public repository. You have to add them manually into your local repository. Run the Maven install commands:

mvn install:install-file  -Dfile=[path to]/testability-explorer-1.3.0-r275.jar \ -DartifactId=testability-explorer -Dversion=1.3 \
-Dpackaging=jar -DcreateChecksum=true

mvn install:install-file  -Dfile=[path to]/ant-testability-explorer-1.3.0-r275.jar \ -DartifactId=ant-testability-explorer -Dversion=1.3 \
-Dpackaging=jar -DcreateChecksum=true

You are now ready to use the Testability Explorer in a Maven 2 powered project locally.

Running the Ant Task from Maven

Now that you have the JAR files available locally, you can use the maven-antrun-plugin to run the Testability Explorer during builds. Go to the build section of your pom.xml and add the following plugin (if you do not have a build section in your pom.xml, you have to create <build> and <plugins> first).


                    <id>Testability Explorer</id>
                            <path id="ant.classpath">
                                <path refid="maven.runtime.classpath" />

                            <echo message="Running Testability Explorer" />

                            <property name="" value="target/reports/testability" />
                            <delete dir="${}" />
                            <mkdir dir="${}" />

                            <taskdef name="testability" classname="">
                                <classpath refid="maven.runtime.classpath" />
                            <testability filter="my.package" resultfile="${}/results.xml" print="xml">
                                <classpath refid="maven.runtime.classpath" />

                            <echo message="Done. Reports can be found in ${}/results.xml" />


This will execute the during the test phase of a Maven 2 run, ie. if you run mvn test. Note: in the XML snippet above you have to replace my.package with your own Java package that you want to have tested.


The suggested solution is far from optimal. As the JAR files will become available in a public Maven 2 repository, you will not have to copy them manually into you local repository. Sooner or later, there will also be am official Maven 2 plugin, so that the maven-antrun-plugin will not be required anymore.

Attachments: (application/zip)