SoapUI Tests with Ant+Ivy
Do you like quest games? Everybody likes! Today we had to play one. It’s name was “run SoapUI tests with ANT script”.
SoapUI is de-facto number 1 tool for testing SOA services. It’s yound enough to have Maven 2 plugin, and it’s old enough to have Maven 1 plugin. But we are not lucky enough: SoapUI doesn’t have Ant task. This article shows how to run SoapUI tests from Ant script.We suppose you are already using Ivy. So, let’s begin.
Ant script
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>
Yes, 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. It’s common to declare them in SoapUI’s global properties. Fortunately, these can be stored in VCS in file soapui-settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 for download ~60 MB of jars. I have no idea why SoapUI needs so much (for example, why it needs javax.jms?), but that’s Java, guys. After running, you will find JUnit-style html reports in folder reports/html. And several log files in the test-results folder.
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 get this problem with javax.jms:jms artifact.
[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
Workaround is simple:rm -fr ~/.ivy2/cache/javax.jms/jms
Conclusion
Though SOA concept is 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 programmer’s quest game. Maven repository is inevitable beast of satan at the end of level. Be patient and kill this boss.
Our recent stories
Partnering with Nicigas in their Energy Development Business
In Codeborne we have built energy information systems in Estonia, Sweden, Norway, Denmark, Luxembourg, Austria, and Japan. With Nicigas we combined our expertise and skillset to create something new on the Japanese market.
From wine tasting to digital innovation- the birth of the Wine Experience Club
We recently sat down with our client, Rait Maasikas, to go deeper into the story behind one of our more unusual recent projects- the Wine Experience Club.
Innovating the Austrian energy market with Spotty Smart Energy Partner
Spotty Smart Energy Partner GmbH, an Austrian energy provider, partnered with Codeborne to enhance their services and bring innovative energy solutions to the market