Over a million developers have joined DZone.

SoapUI Tests with Ant+Ivy

DZone 's Guide to

SoapUI Tests with Ant+Ivy

· Java Zone ·
Free Resource

Do you like quest games? Everybody does!

Today we had to play one. It's name was "run SoapUI tests with ANT script". It was the required step for accessing the next level: "Automated testing of our services on Continuous Integration server".

SoapUI is my de facto tool for testing SOA services. It has a Maven 2 plugin, and it's old enough to have Maven 1 plugin. But we are not quite lucky enough: SoapUI doesn't have Ant tasks.

This article shows how to run SoapUI tests from an Ant script. We suppose you are already using Apache Ivy in this tutorial.

So, let's begin.

Ant script

The Ant task is simple enough:
<target name="test">
    <mkdir dir="test-results"/>
    <java classname="com.eviware.soapui.tools.SoapUITestCaseRunner" errorproperty="tests-failed" fork="yes" dir="test-results">
      <arg line="-j -f${basedir}/test-results"/>
      <arg value="-t${basedir}/soapui-settings.xml"/>
      <arg value="${basedir}/MY-SMART-soapui-project.xml"/>
        <fileset dir="lib" includes="*.jar"/>

    <junitreport todir="test-results">
      <fileset dir="test-results">
        <include name="TEST-*.xml"/>
      <report format="frames" todir="reports/html"/>

    <fail if="tests-failed"/>

Ivy configuration

Next, you need to add corresponding dependencies to ivy.xml:
<dependencies defaultconf="default->default">
    <dependency org="junit" name="junit" rev="4.10+" />
    <dependency org="eviware" name="maven-soapui-plugin" rev="4.0.1" />
    <dependency org="net.sf.jtidy" name="jtidy" rev="r938+"/>
    <exclude org="jtidy" module="jtidy"/>
And finally, you need to add eviware.com repository to your ivysettings.xml:
  <settings defaultResolver="default"/>

    <ibiblio name="public" m2compatible="true"/>
    <ibiblio name="eviware" m2compatible="true" root="http://www.eviware.com/repository/maven2/"/>
    <chain name="default" returnFirst="true">
      <resolver ref="eviware"/>
      <resolver ref="public"/>
Note that eviware should come first, because it overrides some artifacts from the central repository, e.g. javax.jms:jms.

SoapUI settings

Typically all tests have some configuration parameters. In the case of SoapUI, it's common to declare them in global properties. Fortunately, these can be stored in a VCS within soapui-settings.xml:
<con:soapui-settings xmlns:con="http://eviware.com/soapui/config">
  <con:setting id="GlobalPropertySettings@properties"><![CDATA[<xml-fragment xmlns:con="http://eviware.com/soapui/config">
  <property xmlns="http://eviware.com/soapui/config">


ant test
and be prepared to download ~60 MB of jars. I have no idea why SoapUI needs so much (for example, why does it needs javax.jms?), but that's Java, guys. After running Ant tests, you will find JUnit-style HTML reports in folder reports/HTML, and several log files in the test-results folder for deeper debugging.


Missing dependencies

Since eviware repo overrides some artifacts from the central repository, you can get in trouble if some artifacts are already cached in your local repository. For example, we have had this problem with javax.jms:jms artifact. The central repository contains only poms claiming that there is no such jar, but eviware repo contains this jar. If the former has occasionally gotten downloaded into your local cache, you will get the following error:
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve]   [NOT FOUND  ] javax.jms#jms;1.1!jms.jar (0ms)
[ivy:retrieve]  ==== public: tried
[ivy:retrieve]    http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
[ivy:retrieve]   ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]   ::              FAILED DOWNLOADS            ::
[ivy:retrieve]   :: ^ see resolution messages for details  ^ ::
[ivy:retrieve]   ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]   :: javax.jms#jms;1.1!jms.jar
[ivy:retrieve]   ::::::::::::::::::::::::::::::::::::::::::::::
But the workaround is simple:
rm -fr ~/.ivy2/cache/javax.jms/jms


Although I find that SOA concepts are the offspring of the devil, SoapUI is a great tool for testing this, and automated testing is a great practice. Putting them together is a good level for the'programmer's quest game'. A Maven repository is the inevitable beast of satan at the end of level. Be patient and kill this boss.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}