DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > SoapUI Tests with Ant+Ivy

SoapUI Tests with Ant+Ivy

Andrei Solntsev user avatar by
Andrei Solntsev
·
Apr. 24, 12 · Java Zone · Interview
Like (0)
Save
Tweet
10.16K Views

Join the DZone community and get the full member experience.

Join For Free

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"/>
      <classpath>
        <fileset dir="lib" includes="*.jar"/>
      </classpath>
    </java>

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

    <fail if="tests-failed"/>
  </target>

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"/>
  </dependencies>
And finally, you need to add eviware.com repository to your ivysettings.xml:
<ivysettings>
  <settings defaultResolver="default"/>

  <resolvers>
    <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"/>
    </chain>
  </resolvers>
</ivysettings>
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">
    <name>MY_serverUrl
    <value>http://my-dev-server.chucknorris.com:8080
  </property>
  <con:property>
    <con:name>MY_dbConnectionString
    <con:value>jdbc:oracle:thin:chuck/donteventry@dev.chucknorris.com:1521:dev
  </con:property>
</xml-fragment>]]></con:setting>
</con:soapui-settings>

Running

Execute
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.

Troubleshooting

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]   ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] 
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
But the workaround is simple:
rm -fr ~/.ivy2/cache/javax.jms/jms

Conclusion

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.

Testing

Published at DZone with permission of Andrei Solntsev. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How Database B-Tree Indexing Works
  • APIs Outside, Events Inside
  • What Is ERP Testing? - A Brief Guide
  • 3 Predictions About How Technology Businesses Will Change In 10 Years

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo