Wednesday, August 20, 2014

Run soapui project using maven plugin

SoupUI is a very useful tool that you can  use for test web and other services. Users can create soapui project to send requests and do validations on that. We need to find a way to automate running these soapui projects, so that the test case writer can easily integrate many tests created with soapui to the existing maven projects. In the following steps we will describe how to automate running projects created with soapui within a maven project.

Create your soapui project


You have to create your soapui project first. In the example project we have given here, used existing wsdl files provided with echo and version services shipped with WSO2 ESB.  When you create project with soapui, you have to make sure to pick the option of creating test cases with it.


1.jpg

Add Assertions with soapui projects


You need to configure assertions which needs to be validated against the inputs given in the test cases. If assertion occurs you can view it within the maven build. To create assertion follow the document [1].

Configure maven project


Once you have finished creating soapui project and its assertions you have to save it. The output file will be in xml format. To run soapui project file we use the Maven Soapui Extension Plugin [2].  In this plugin you can run multiple soapui projects to run. In order to do that you have to set the goal as test-multi. Given below is the sample configuration for that.


 <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.github.redfish4ktc.soapui</groupId>  
         <artifactId>maven-soapui-extension-plugin</artifactId>  
         <version>4.6.4.1</version>  
         <executions>  
           <execution>  
             <id>soapUI1</id>  
             <phase>test</phase>  
             <goals>  
               <goal>test-multi</goal>  
             </goals>  
             <configuration>  
               <projectFiles>  
                 <scan>  
                   <baseDirectory>/home/waruna/workspace/soapuitest/src/main/resources/projects</baseDirectory>  
                   <includes>  
                     <include>*.xml</include>  
                   </includes>  
                   <excludes>  
                     <exclude>**/*fail-*-soapui-project.xml</exclude>  
                     <exclude>**/composite-projects/**</exclude>  
                   </excludes>  
                 </scan>  
               </projectFiles>  
               <outputFolder>/home/waruna/workspace/soapuitest/src/main/resources/</outputFolder>  
               <junitReport>true</junitReport>  
               <useOutputFolderPerProject>true</useOutputFolderPerProject>  
             </configuration>  
           </execution>  
         </executions>  
       </plugin>  
     </plugins>  
   </build>  
 </project>  
[2]http://mvnrepository.com/artifact/com.github.redfish4ktc.soapui/maven-soapui-extension-plugin

1 comment:

  1. Could you please share any video where you configured SOAP UI with robotframework and run some test cases.

    ReplyDelete