ProductivityAndFun Download Trial - Free 14 day evaluation

Maven

PDF Print E-mail
User Rating:  / 20
Rate this article: PoorBest 

1. Maven

NOTE! As of version 5.1.0 some users might experience problems with the maven plugin. If youare getting a NoClassDefFoundError: org/reflections/Configuration or org/apache/poi/ss/usermodel/Workbook when running the plugin, please add the reflections dependency explicitly as described below:
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-pro-maven-plugin</artifactId>
<version>5.1.1</version>
<configuration>
</configuration>
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC1</version>

</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10-FINAL</version>
</dependency>
</dependencies>
</plugin>
Please use this workaround while we work to resolve the issue permanently.

2. Basic Configuration

SoapUI includes a Maven (version 2 and above) plugin for running SoapUI tests and mocks during a Maven build.
In the examples below we're using the 4.6.1 version of the plugins. Please see our public SoapUI Open Source and SoapUI Pro Maven repositories for which versions that are currently available.
Note that we're also providing maintenance build versions of the plugins (marked with a -m-SNAPSHOT suffix).

Note! If integrating with SoapUI Pro, use the Pro version of the plugin.

Prior to using the plugin, add the SmartBear Maven 2 repository either to your project or settings.xml:

<pluginRepositories>
    <pluginRepository>
        <id>smartbear-sweden-plugin-repository</id>
        <url>http://www.soapui.org/repository/maven2/</url>
    </pluginRepository>
</pluginRepositories>


Then, add the SoapUI plugin to your pom.xml:

<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>4.6.1</version>
<configuration>
<projectFile>simple-test-soapui-project.xml</projectFile>
<projectProperties>
<value>message=Hello World!</value>
</projectProperties>
</configuration>
</plugin>
</plugins>

 

3. Running Tests

Run functional tests with

mvn com.smartbear.soapui:soapui-maven-plugin:4.6.1:test

loadtests with

mvn com.smartbear.soapui:soapui-maven-plugin:4.6.1:loadtest

and MockServices with

mvn com.smartbear.soapui:soapui-maven-plugin:4.6.1:mock

The plugin will load the specified project file and run all TestCases available in all TestSuites. If you want to narrow down which TestSuites/TestCases/LoadTest to run, use the testSuite, testCase and loadTest properties for that purpose.

4. Integrated Tools

If you configure any of the integrated code generation tools in SoapUI for an interface in your project, you can invoke this code generation functionality with

mvn com.smartbear.soapui:soapui-maven-plugin:4.6.1:tool

which could be configured in the Maven 2 build process as part of the generate-sources step:

<plugins>
  <plugin>
    <groupId>com.smartbear.soapui</groupId>
    <artifactId>soapui-maven-plugin</artifactId>
    <version>4.6.1</version>
    <configuration>
         <projectFile>sample-soapui-project.xml</projectFile>
         <testSuite>OleTest</testSuite>
         <iface>IOrderService</iface>
         <tool>wsi,axis1,axis2</tool>
         <settingsFile>C:\workspace\core\soapui-settings.xml</settingsFile>
     </configuration>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
        </execution>
      </executions>
  </plugin>
</plugins>

Several tools can be specified in a comma separated list, so the above example would run both WS-I reports and configured code generation for both Axis1 and Axis2. Also, the SoapUI settings file has been specified since it contains tool paths and global WS-I settings

5. Plugin Goals

  • test : Runs the SoapUI tests as specified by the plugin properties. Internally invokes the SoapUITestCaseRunner class as described there.
  • loadtest : Runs the SoapUI loadtests as specified by the plugin properties. Internally invokes the SoapUILoadTestRunner class as described there.
  • tool : Runs the specified and configured code-generation tool. Internally invokes the SoapUIToolRunner class as described there.
  • mock : Runs the specified and configured code-generation tool. Internally invokes the SoapUIMockServiceRunner class as described there.

6. Plugin Settings

6.1. test settings

  • projectFile : Specified the name of the SoapUI project file to use, default value is ${pom.artifactId}-soapui-project.xml
  • testSuite : Specifies the name of the TestSuite to run
  • testCase : Specifies the name of the TestCase to run
  • endpoint : Overrides the service endpoint to be invoked by any TestRequests
  • host : Overrides the target host:port to be invoked by any TestRequests
  • username : Overrides the username used by any TestRequests run
  • password : Overrides the password used by any TestRequests run
  • domain : Overrides the domain used by any TestRequests run
  • printReport : Controls if a small test report should be printed to the console (true/false)
  • outputFolder : Set which folder results/reports are saved to
  • junitReport : Turns on creation of JUnit-reports, (true/false)
  • exportAll : Controls if all test requests should be exported (default only exports errors), (true/false)
  • settingsFile : Specifies SoapUI settings file to use
  • wssPasswordType : Specifies WSS password type
  • project.password : Specifies password for encrypted project
  • settingsFile.password : Specifies password for encrypted settings file
  • globalProperties : Sets global properties
  • projectProperties : Sets project properties
  • saveAfterRun : Saves project file after run
  • testFailIgnore : Ignore failed tests.
  • reportFormat : Sets formats for created report. Pro only.
  • reportName : Sets which report to create. Pro only.
  • coverage : Sets the output to include Coverage HTML reports. Pro only.
  • environment : Sets the active environment. Pro only.

6.2. loadtest settings

  • projectFile : Specified the name of the SoapUI project file to use, default value is ${pom.artifactId}-soapui-project.xml
  • testSuite : Specifies the name of the TestSuite to run
  • testCase : Specifies the name of the TestCase to run
  • loadTest : Specifies the name of the LoadTest to run (if running the soapui:loadtest goal)
  • limit : Overrides the limit of executed LoadTests (if running the soapui:loadtest goal)
  • endpoint : Overrides the service endpoint to be invoked by any TestRequests
  • host : Overrides the target host:port to be invoked by any TestRequests
  • username : Overrides the username used by any TestRequests run
  • password : Overrides the password used by any TestRequests run
  • domain : Overrides the domain used by any TestRequests run
  • printReport : Controls if a small test report should be printed to the console (true/false)
  • outputFolder : Set which folder results/reports are saved to
  • settingsFile : Specifies SoapUI settings file to use
  • settingsFile.password : Specifies soapui-settings file password if it is encrypted.
  • project.password : Specifies password if project file is encrypted.
  • wssPasswordType : The WSS password-type to use for any authentications.
  • saveAfterRun : Saves project file after run.
  • threadcount : Number of threads in loadtest.
  • reportName : Sets which report to create. Pro only.
  • reportFormat : Sets formats for created report. Pro only.

6.3. tool settings

  • projectFile : Specified the name of the SoapUI project file to use, default value is ${pom.artifactId}-soapui-project.xml
  • iface : Specifies the interface to generate for
  • tool : Specifies the tool(s) to run, a comma-separated list of axis1, axis2, dotnet, gsoap, jaxb, wstools, wsconsume, ora, wscompile, wsi, wsimport, xfire or xmlbeans
  • settingsFile : Specifies SoapUI settings file to use, will contain path to integrated tool to run
  • project.password : Specifies password for encrypted project file
  • settingsFile.password : Specifies password for encrypted soapui settings file
  • outputFolder : Set which folder results/reports are saved to

6.4. mock settings

  • projectFile : Specified the name of the SoapUI project file to use, default value is ${pom.artifactId}-soapui-project.xml
  • mockService : Specified the MockService to run
  • port : The local port to listen on, overrides the port configured for the MockService
  • path : The local path to listen on, overrides the path configured for the MockService
  • noBlock : Turns off blocking when MockRunner has started
  • settingsFile : Specifies SoapUI settings file to use, will contain path to integrated tool to run
  • project.password : Specifies password for encrypted project file
  • settingsFile.password : Specifies password for encrypted soapui settings file
  • saveAfterRun : Saves project file after run.

7. Full Example

The example below is a complete pom for configuring the Maven 2 plugin, please note
1) the jdbc-driver dependency required for JDBC Testing in the project
2) the project-property override

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.smartbear.samples</groupId>
    <artifactId>soapui-maven2-plugin</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Maven 2 SoapUI Sample</name>
    <url>http://maven.apache.org</url>
    <pluginRepositories>
        <pluginRepository>
            <id>SmartBearPluginRepository</id>
            <url>http://www.soapui.org/repository/maven2/</url>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <plugins>
            <plugin>
                <groupId>com.smartbear.soapui</groupId>
                <artifactId>soapui-pro-maven-plugin</artifactId>
                <version>4.6.1</version>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.6</version>
                    </dependency>
                </dependencies>    
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <projectFile>simple-test-soapui-project.xml</projectFile>
                            <projectProperties>
                                <value>message=Hello World!</value>
                            </projectProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

NOTE! The Maven 1 plugins has been deprecated since SoapUI version 3.6 and will no longer recive any updates.

The soapUI Maven plugin for maven 1.x allows you to run soapUI functional and load tests within a maven build.

Prior to installing a new version of the plugin, you should delete any old versions from you local cache, repository, maven installation.

Download the latest version of the plugin from sourceforge soapUI Downloads or install it directly from the command line:

maven plugin:download -DgroupId=eviware -DartifactId=maven-soapui-plugin 
-Dversion=1.6 -Dmaven.repo.remote=http://www.soapui.org/repository

Alternatively you can specify a dependency directly in your project.xml;

<dependency>
    <groupId>eviware</groupId>
    <artifactId>maven-soapui-plugin</artifactId>
    <version>1.7.6</version>
    <type>plugin</type>
</dependency>

In this case, don't forget to add the soapUI repository to your repository list in project.properties;

maven.repo.remote=http://www.ibiblio.org/maven,http://www.soapui.org/repository

7.1. soapUI Maven Plugin Usage

Download and install the plugin as described above. By default, it will look for a soapUI project file named${pom.artifactId}-soapui-project.xml, you can override this by setting with the maven.soapui.project property.

Run functional tests with

maven soapui:test

and load tests with

maven soapui:loadtest

The plugin will load the specified project file and run all TestCases available in all TestSuites. If you want to narrow down which TestSuites/TestCases/LoadTest to run, use the maven.soapui.test.testsuitemaven.soapui.test.testcaseand maven.soapui.test.loadtest properties for that purpose.

If you want to change the service endpoint, host, username, password or domain used by the TestRequests in the executed TestCases, set this with one of the maven.soapui.test.XX properties, for example

maven soapui:test -Dmaven.soapui.test.endpoint=http://somehost.com:8080/services/MyService

Be aware that this will set the endpoint for all TestRequests executed, you might need to narrow down which TestCase to run if you have multiple TestCases testing multiple services.

For example if you have 2 TestSuites, each testing its own service in your project, you could run these as follows;

maven soapui:test -Dmaven.soapui.test.testsuite=TestSuite1 
	-Dmaven.soapui.test.endpoint=http://somehost.com:8080/services/MyService1

followed by

maven soapui:test -Dmaven.soapui.test.testsuite=TestSuite2 
	-Dmaven.soapui.test.endpoint=http://someotherhost.com:8080/services/MyService2

Turn on creation of simple reports as described for the command line SoapUITestCaseRunner and SoapUITestCaseRunner runners with the maven.soapui.report.XX properties.

Sample Outputs from the Maven plugin

Here comes an example output when running soapUI functional tests through maven as described above using the sample project included in the offline distribution:

maven soapui:test -Dmaven.soapui.project=sample-soapui-project.xml
 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0.2

build:start:

soapui:test:
    [echo] Running soapUI project sample-soapui-project.xml with endpoint []
    [java] SoapUI 2.5.1 TestRunner
    [java] 23:57:56,258 INFO  [SoapUITestCaseRunner] setting projectFile to [sample-soapui-project.xml]
    [java] 23:57:56,838 INFO  [WsdlProject] Loaded project from [sample-soapui-project.xml]
    [java] 23:57:57,219 INFO  [SoapUITestCaseRunner] Running soapui tests in project [Sample Project]
    [java] 23:57:57,219 INFO  [SoapUITestCaseRunner] Running soapui suite [Test Suite]
    [java] 23:57:57,219 INFO  [SoapUITestCaseRunner] Running soapui testcase [Test Conversions]
    [java] 23:57:57,219 INFO  [SoapUITestCaseRunner] runing step [SEK to USD Test]
    [java] Retrieving document at 'http://www.webservicex.net/CurrencyConvertor.asmx?WSDL'.
    [java] 23:57:59,893 INFO  [SchemaUtils] Loading schema types from [http://www.webservicex.net/CurrencyConvertor.asmx?WSDL]
    [java] 23:57:59,893 INFO  [SchemaUtils] loading schema types from http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
    [java] Assertion [Schema Compliance] has status VALID
    [java] Assertion [XPath Match - check for less than 0.2] has status VALID
    [java] Assertion [XPath Match - check for more than 0.1] has status VALID
    [java] Assertion [SOAP Fault Assertion] has status VALID
    [java] 23:58:01,025 INFO  [SoapUITestCaseRunner] runing step [USD to SEK Test]
    [java] Assertion [Schema Compliance] has status VALID
    [java] Assertion [XPath Match - check for less than 8] has status VALID
    [java] Assertion [XPath Match - check for more than 7] has status VALID
    [java] Assertion [SOAP Fault Assertion] has status VALID
    [java] 23:58:01,495 INFO  [SoapUITestCaseRunner] Finished running soapui testcase [Test Conversions], time taken = 4276ms
    [java] 23:58:01,505 INFO  [SoapUITestCaseRunner] Running soapui testcase [Test XMethods Query]
    [java] 23:58:01,505 INFO  [SoapUITestCaseRunner] runing step [Test getAllServiceNames]
    [java] Assertion [XPath Match - check for Anagram Service] has status VALID
    [java] 23:58:03,488 INFO  [SoapUITestCaseRunner] runing step [Transfer values]
    [java] 23:58:03,688 INFO  [SoapUITestCaseRunner] runing step [Test getServiceDetail]
    [java] Assertion [XPath Match] has status VALID
    [java] 23:58:03,949 INFO  [SoapUITestCaseRunner] Finished running soapui testcase [Test XMethods Query], time taken = 2444ms
    [java] 23:58:03,959 INFO  [SoapUITestCaseRunner] soapui suite [Test Suite] finished in 6740ms
BUILD SUCCESSFUL
Total time: 10 seconds
Finished at: Sun Oct 02 23:58:04 CEST 2005

Another sample with a failed loadtest:

maven soapui:loadtest -Dmaven.soapui.test.loadtest=LoadTest1 -Dmaven.soapui.report.folder=results
 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0.2

Attempting to download swingx-SNAPSHOT.jar.
build:start:

soapui:loadtest:
    [echo] Running soapui project jbossws-soapui-project.xml with endpoint []
    [java] SoapUI 2.5.1 LoadTestRunner
    [java] 22:48:13,116 INFO  [SoapUILoadTestRunner] setting projectFile to [jbossws-soapui-project.xml]
    [java] 22:48:13,116 INFO  [SoapUILoadTestRunner] setting testSuite to [test]
    [java] 22:48:13,116 INFO  [SoapUILoadTestRunner] setting testCase to [testcase3]
    [java] 22:48:13,647 INFO  [WsdlProject] Loaded project from [jbossws-soapui-project.xml]
    [java] 22:48:14,818 INFO  [SoapUILoadTestRunner] Skipping testcase [testing], filter is [testcase3]
    [java] 22:48:14,818 INFO  [SoapUILoadTestRunner] Skipping testcase [testcase2], filter is [testcase3]
    [java] 22:48:14,818 INFO  [SoapUILoadTestRunner] Running LoadTest [LoadTest1]
    [java] 22:48:14,878 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.0
    [java] 22:48:15,870 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.038
    [java] 22:48:16,871 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.102
    [java] 22:48:17,873 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.14
    [java] 22:48:18,884 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.204
    [java] 22:48:19,876 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.274
    [java] 22:48:20,887 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.35
    [java] 22:48:21,889 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.424
    [java] 22:48:22,890 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.488
    [java] 22:48:23,891 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.564
    [java] 22:48:24,893 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] progress: 0.642
    [java] 22:48:25,894 INFO  [SoapUILoadTestRunner] LoadTest [LoadTest1] finished with status FAILED
    [java] 22:48:25,894 INFO  [SoapUILoadTestRunner] Exporting log and statistics for LoadTest [LoadTest1]
    [java] 22:48:25,944 INFO  [SoapUILoadTestRunner] Exported 36 log items to [results\LoadTest1-log.txt]
    [java] 22:48:26,265 INFO  [SoapUILoadTestRunner] Exported 33 error results
    [java] 22:48:26,265 INFO  [SoapUILoadTestRunner] Exported 3 statistics to [results\LoadTest1-statistics.txt]
    [java] 22:48:26,265 INFO  [SoapUILoadTestRunner] Skipping testcase [testcase4], filter is [testcase3]
    [java] 22:48:26,265 INFO  [SoapUILoadTestRunner] soapui suite [test] finished in 11447ms
    [java] 22:48:26,265 INFO  [SoapUILoadTestRunner] 1 load tests failed:
    [java] 22:48:26,265 INFO  [SoapUILoadTestRunner] LoadTest1: Maximum number of errors [30] exceeded for step [Groovy Script]
    [java] 22:48:26,265 ERROR [SoapUILoadTestRunner] com.eviware.soapui.support.SoapUIException: LoadTests failed

BUILD FAILED
File...... C:\Documents and Settings\ole.matzura\.maven\cache\maven-soapui-plugin-1.5beta1\plugin.jelly
Element... ant:java
Line...... 104
Column.... 105
Java returned: 1
Total time: 18 seconds
Finished at: Sun Mar 12 22:48:26 CET 2006

7.2. Plugin Goals

  • soapui:test : Runs the soapUI tests as specified by the plugin properties. Internally invokes the SoapUITestCaseRunner as described there.
  • soapui:loadtest : Runs the soapUI LoadTests as specified by the plugin properties. Internally invokes the SoapUILoadTestRunner as described there.
  • soapui:mock : Runs the soapUI MockService specified by the plugin properties. Internally invokes the

7.3. Plugin Properties

The following properties are available for configuring the plugin functionality. * = required, values in parentheses at the end specify for which goals the property is applicable.

  • maven.soapui.project : Specifies the name/URL of the soapUI project file to use, default value is ${pom.artifactId}-soapui-project.xml (test, loadtest, mock)
  • maven.soapui.test.testsuite : Specifies the name of the TestSuite to run (test,loadtest)
  • maven.soapui.test.testcase : Specifies the name of the TestCase to run (test,loadtest)
  • maven.soapui.test.loadtest : Specifies the name of the LoadTest to run (loadtest)
  • maven.soapui.test.limit : Overrides the limit of executed LoadTests (loadtest)
  • maven.soapui.test.endpoint : Overrides the service endpoint to be invoked by any TestRequests test (loadtest)
  • maven.soapui.test.host : Overrides the target host:port to be invoked by any TestRequests (test,loadtest)
  • maven.soapui.test.username : Overrides the username used by any TestRequests run (test,loadtest)
  • maven.soapui.test.password : Overrides the password used by any TestRequests run (test,loadtest)
  • maven.soapui.test.domain : Overrides the domain used by any TestRequests run (test,loadtest)
  • maven.soapui.report : Controls if a small test report should be printed to the console (yes/no) (test,loadtest)
  • maven.soapui.report.folder : Set which folder results/reports are saved to (test,loadtest)
  • maven.soapui.report.junit :Turns on creation of JUnit reports (test)
  • maven.soapui.report.all :Controls if all test requests should be exported (default only exports errors), (yes/no) test)
  • maven.soapui.mock.service * : Sets which MockService to run with the soapui:mock goal (mock)
  • maven.soapui.mock.port : Sets which port to listen on locally when mocking (mock)
  • maven.soapui.mock.path : Sets which path to listen on locally when mocking (mock)
  • maven.soapui.mock.noblock  : Turns off blocking when MockRunner has started (mock)
  • maven.soapui.settings : Path to soapui-settings.xml (test,loadtest,mock)
  • maven.soapui.settings.password : soapui-settings.xml password if it is encrypted (test,loadtest,mock)
  • maven.soapui.project.password :project password if it is encrypted (test,loadtest,mock)
  • maven.soapui.test.FailIgnore :Do not stop if error occurs, ignore them (test)
  • maven.soapui.test.wssPasswordType :Sets the WSS password type, either 'Text' or 'Digest' (test,loadtest)
  • maven.soapui.test.save :Saves the project after running the tests (test,loadtest,mock)
  • maven.soapui.test.threadcount : Sets number of running threads (loadtest)
  • maven.soapui.createCoverage :Sets the output to include Coverage HTML reports. Pro only. (test)
  • maven.soapui.reportFormat :Sets formats for created report. Pro only. (test)
  • maven.soapui.reportName :Sets which report to create. Pro only. (test)

System properties can be set by -D and global properties by -G.