转: http://www.soapui.org/Test-Automation/maven-2x.html
转:http://blog.karit.geek.nz/2009/08/using-soapui-to-do-testing-as-part-of.html
1. Basic Configuration
soapUI includes a Maven 2.x plugin for running soapUI tests and mocks during a maven build. Prior to using the plugin, add the eviware maven 2 repository either to your project or settings.xml;
<pluginRepositories>
<pluginRepository>
<id>eviwarePluginRepository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
(Note: If integrating with SoapUI Pro, use the Pro version of the plugin)
Then, add the soapUI plugin to your pom.xml
<plugins>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<projectFile>sample-soapui-project.xml</projectFile>
<host>http://127.0.0.1:8181</host>
</configuration>
</plugin>
</plugins>
2. Running Tests
Run functional tests with
mvn eviware:maven-soapui-plugin:test
loadtests with
mvn eviware:maven-soapui-plugin:loadtest
and MockServices with
mvn eviware:maven-soapui-plugin: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 loadTestproperties for that purpose.
3. 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 eviware:maven-soapui-plugin:tool
which could be configured in the maven 2 build process as part of the generate-sources step:
<plugins>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>2.5.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
4. Plugin Goals
- maven-soapui-plugin:test : Runs the soapUI tests as specified by the plugin properties. Internally invokes the SoapUITestCaseRunner class as described there.
- maven-soapui-plugin:loadtest : Runs the soapUI loadtests as specified by the plugin properties. Internally invokes the SoapUILoadTestRunner class as described there.
- maven-soapui-plugin:tool : Runs the specified and configured code-generation tool. Internally invokes the SoapUIToolRunner class as described there.
- maven-soapui-plugin:mock : Runs the specified and configured code-generation tool. Internally invokes the SoapUIMockServiceRunner class as described there.
5. Plugin Settings
5.1. eviware:soapui: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.
5.2. eviware:soapui: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.
5.3. eviware:soapui: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
5.4. eviware:soapui: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.
6. 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>eviwarePluginRepository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-pro-plugin</artifactId>
<version>4.0.0</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>