Configure Ant Task for Running SoapUI as JUnit Test

There have been some blog posts regarding running SoapUI using either testrunner.bat or scripts coming with SoapUI installation. You can choose either bat or sh script based on your OS. But what if I need a solution that works on both Windows and Linux? There  are also posts mentioning reading the SoapUI project file and creating custom JUnit test class to run each test case inside test suite. Is there another way ?

What “testrunner” does is simply to run a Java program (with as Main class) and generates JUnit reports.  What we can do is to configure an Ant task running the very same Java class with the same configurations.

Ant Task Configuration

Ant target configuration

After running this target, JUnit reports will be generated in the pre-defined directory. If you are using CI server (such as Bamboo), since build plan is configured to look for JUnit results, in the email sent out by Bamboo after each build you can see which test case failed if any.    Voilà

Configure Ant Task for Running SoapUI as JUnit Test

Configure Clover and Sonar Ant Tasks for Code Coverage

Using Cobertura or Clover to generate code coverage reports is a relatively straightforward task as there have been some examples out there to begin with. On the other hand, being able to see coverage number generated by Clover in Sonar console takes a little bit extra configuration as Sonar by default is using Cobertura as code coverage plugin.

Ant Tasks Configuration

Sonar Ant target configuration(with dynamic analysis)

Sonar Ant target configuration(with reuseReports)

Clover Ant target configuration

Ant Command

ant   with.clover   test   sonar

(test target is the one to compile source code and run JUnit test, replace it with your own one)

Sonar Server Configuration

There was something I have been missing and kept me from seeing the code coverage number showing up in Sonar console after running the above mentioned Ant command. Despite already setting “sonar.core.codeCoveragePlugin” property to “clover”, I was still not able to see the coverage number. It turned out that the answer is right there in the Sonar Clover Plugin instruction.

What I was missing is adding Sonar Clover Plugin jar file into Sonar core-plugins directory.


It is also important to configure Sonar’s Global or Project settings to specify using “clover” as code coverage plugin.

Configure Clover and Sonar Ant Tasks for Code Coverage