Sunday, 30 August 2009

Using soapUI to do testing as part of a Maven2 build

soapUI has a Maven plugin. soapUI has a Maven getting started guide and Maven has a Maven getting started guide. Well I thought I would have a go at joining them together, so I can a Maven script automatically run my soapUI tests and output a jUnit compatible results file.

Pre Reqs:
  • Maven 2 installed
  • soapUI with a project that already has some tests setup

Steps:
  1. Setup a new project. This will create you a new project in a new directory called app. To do this run "mvn archetype:create -DgroupId=nz.geek.karit.app -DartifactId=app"
  2. To pom.xml add:
    <!--Add the repository for where Maven can find the soapUI Plugin-->
    <pluginRepositories>
    <pluginRepository>
    <id>eviwarePluginRepository</id>
    <url>http://www.eviware.com/repository/maven2/</url>
    </pluginRepository>
    </pluginRepositories>
    <build>
    <plugins>
    <plugin>
    <groupId>eviware</groupId>
    <artifactId>maven-soapui-plugin</artifactId>
    <!--This is the version of soapUI to grab from plugin repo-->
    <!--At the time of writing the 3.0.1 plugin had not been created-->
    <version>2.5.1</version>
    <configuration>
    <!--The location of your soapUI setting file-->
    <projectFile>/home/test/test.xml</projectFile>
    <!--Where to place the output of the run-->
    <outputFolder>/home/test/output/</outputFolder>
    <!--Make the jUnit results file-->
    <junitReport>true</junitReport>
    </configuration>
    <executions>
    <execution>
    <id>soapUI</id>
    <!--Run as part of the test phase in the Maven lifecycle-->
    <phase>test</phase>
    <goals>
    <!--Run the test phase of eviware:maven-soapui-plugin-->
    <goal>test</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>

  3. You can now run the soapUI tests by calling "mvn eviware:maven-soapui-plugin:test"
  4. It will also run as part of Maven with "mvn test" for example

For all the different properties you can set see: http://www.soapui.org/plugin/maven2/properties.html

Along with running the test you can also run the loadtests and start the mock web service all from Maven. You can do this by calling a goal other than test. For the details see: http://www.soapui.org/plugin/maven2/goals.html

My full pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nz.geek.karit.app</groupId>
<artifactId>app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<!--Add the repository for where Maven can find the soapUI Plugin-->
<pluginRepositories>
<pluginRepository>
<id>eviwarePluginRepository</id>
<url>http://www.eviware.com/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<!--This is the version of soapUI to grab from plugin repo-->
<!--At the time of writing the 3.0.1 plugin had not been created-->
<version>2.5.1</version>
<configuration>
<!--The location of your soapUI setting file-->
<projectFile>/home/test/test.xml</projectFile>
<!--Where to place the output of the run-->
<outputFolder>/home/test/output/</outputFolder>
<!--Make the jUnit results file-->
<junitReport>true</junitReport>
</configuration>
<executions>
<execution>
<id>soapUI</id>
<!--Run as part of the test phase in the Maven lifecycle-->
<phase>test</phase>
<goals>
<!--Run the test phase of eviware:maven-soapui-plugin-->
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

5 comments:

Gaurav said...

Hi,

USING plugin

eviware maven-soapui-plugin
3.5.1

I am trying to execute SOAPUI test cases from maven project basen on SOAP UI maven plugin.

How can I instruct SOAPUI maven plug-in that we are trying to use license version so that we can use pro functionality via maven plug-in?

Because of above reason some of the test step is not executed properly via maven plug-in as compared to, when we are executing the test cases directly in SOAP UI.

Test steps which is given problem via maven plug-in :-

1. Data source
2. loop

KR,
Gaurav

Karit said...

Sorry I know nothing about the Pro version.

Anonymous said...

As I see in repository that the artifactId should be different for the "pro" version:
eviware
maven-soapui-pro-plugin

But I cannot confirm it because I don't use it.

Axel said...

is it possible to run this by specifying soapUI properties?

Axel said...

is it possible to run this by specifying soapUI parameters?

...in a similar way as when running from command line?