March 03, 2010

Integration of soapUI tests in maven build lifecycle

« SOAP web service testing with soapUI : exceptions | Main | SOAP web service testing with soapUI »

This article extends the basic example described in "Web service testing with soapUI". It describes how to integrate soapUI tests in maven build lifecycle, using maven-jetty-plugin to run the web application and maven-soapui-plugin to run the tests.

That is how it goes:

  1. in the pre-integration-test phase : starts our web application in jetty
  2. in the integration-test phase : runs soapUI tests
  3. in the post-integration-test phase : stops jetty

1. How to configure the jetty plugin

This makes the web application available under http://localhost:8080/trip-price-0.0.1-SNAPSHOT/webservices/TripPriceService

<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>test.webservice.soapui.example</groupId>
  <artifactId>trip-price-war</artifactId>
  <packaging>war</packaging>
  <name>trip-price-war</name>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <finalName>trip-price-${version}</finalName>
    <plugins>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.21</version>
        <configuration>
          <connectors>
            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
              <port>8080</port>
              <maxIdleTime>60000</maxIdleTime>
            </connector>
          </connectors>
          <contextPath>/trip-price-${version}</contextPath>
          <webApp>target/trip-price-${version}.war</webApp>
          <stopKey>foo</stopKey>
          <stopPort>9999</stopPort>
        </configuration>
        <executions>
          <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <scanIntervalSeconds>0</scanIntervalSeconds>
              <daemon>true</daemon>
            </configuration>
          </execution>
          <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

2. How to configure the soapUI plugin

Add the following content under the plugins tag.

      <plugin>
        <groupId>eviware</groupId>
        <artifactId>maven-soapui-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <projectFile>${basedir}/src/test/resources/trip-price-service-soapui-project.xml</projectFile>
          <printReport>true</printReport>
        </configuration>
        <executions>
          <execution>
            <id>soap-integration-test</id>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

You may need to add the following repository.

    <pluginRepository>
      <id>eviwarePluginRepository</id>
      <url>http://www.eviware.com/repository/maven2/</url>
    </pluginRepository>

3. How to run the tests

This will run the tests before installing.

mvn install

Related topics:

"Web service testing with soapUI"
"Web service testing with soapUI: exceptions"

Technorati Tags:

Posted by nadege.griesser at 3:11 PM in Testing

 

[Trackback URL for this entry]

Comment: David at Di, 27 Jul 10:26 AM

Hi Nadege,

thanks a lot for this post. I'm currently trying to test ws client using a soapui Mock. Do you have successfully used maven soapui mock plugin ?

Thanks & Regards,

David.

Comment: David at Di, 27 Jul 12:31 PM

Hi Nadege,

thanks for this interesting post.
Currently I'm trying to use maven soapui mock plugin to test web service client.

Do you have some feedback on it ? My concern is about launching tests while soapui mocks are up.

thanks & regards,

David.

Comment: Nadege at Di, 27 Jul 12:42 PM

Hi David,
As far as I remember, I have not managed to run soapui mocks and tests at the same time using the plugin.
My workaround is to start the mocks with a groovy setup script when running the tests. (as described in 6.2 and 6.3 here http://developers-blog.org/blog/default/2010/03/04/SoapUI-limitations-and-workarounds-mock-response-test-step )
Regards,
Nadege

Comment: David at Di, 27 Jul 1:29 PM

Hi Nadege,

thanks a lot for the quick answer. I will let you know if I find the way to use the SoapUIMockServiceRunner (maven plugin) to test my ws client.

Thanks & Regards,

David.

Comment: Eric P at Sa, 6 Nov 12:41 AM

Thanks for the post. I added the Jetty and SoapUI plugins based your post but I ran into a problem that took me a while to figure out. When SoapUI started up it would just hang. Sometimes Maven would report a FATAL ERROR. It turns out that I needed to bump up both my heap size and my PermGen size, for example: export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"

Thanks again,

Comment: lehari at Mi, 1 Dez 11:26 PM

I have soupUI tests with datasource ( jdbc oracle thin client). when I integrated with maven, I get errors on the JDBC connectivity. Any idea?
The remaining tests which dont have the jdbc step pass.

Comment: alexey anisimov at So, 13 Feb 6:35 PM

maven-soapui-plugin -> under what license this plugin distributed?

Pingback: SoapUI tests in maven Integration - Websphere Tutorial at Di, 7 Jun 2:03 PM

Integration of soapUI tests in maven build lifecycle
is a good tutorial show you how to use SoapUI tests in maven

Comment: remo at Mi, 3 Aug 10:02 AM

I want to run multiple project file using this plugin. Is it possible to do it using this plugin? If yes can you please provide the solution.

Thanks in advance

Comment: Jared at Fr, 12 Aug 4:19 PM

What if a test fails? The soapUI plugin will fail the build in the integration-test phase, and you'll never progress to the post-integration-test phase to shutdown jetty. Maybe this isn't a problem with the Jetty plugin, but it is for me (starting a software stack using exec plugin). Are you able to use something like failsafe-plugin:verify to fail the test AFTER the shutdown?

Your comment:

(not displayed)
 
 
 

Live Comment Preview:

 
« March »
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031