In this article I will explain how to run SOAPUI tests in headless mode. We will use Maven and Jenkins for automation. There is soapui-maven-plugin available to do the job. I assume that you know how to create SOAPUI project and create Test suits/cases. You can refer to SOAPUI tutorial if need help in creating projects/test suits/test cases.
Here I will take a simple example of Functional test; however you can scale it up for load test as well.
Environment:
SOAPUI 5.0.0 (free version)
Maven 3.3.3
Jenkins 1.633
If you want to know how to configure Maven and Jenkins, pls refer to my post :
http://anandawasthitech.blogspot.com/2015/10/iib-continuousintegration-maven-jenkins.html
Step1: Create SOAPUI Project:
Create a SOAPUI project and create a Test Suit. Add a Test case in this Test Suit. You can configure project properties to pass the values dynamically in your request. You can pass the property value using the syntax "${#Project#PropertyName}" See the below example:
Click on the project and click on '+' button under 'Custom Properties'. Add a property name and value. In the soap request, supply this property. Refer to below screen-shot:
Further you can set assertions to validate the response. All this depends on your requirement, you can configure it accordingly.
Let us save the soapui project.
Step2: Update Maven settings.xml:
Add below plugin repository in settings.xml for Maven:
<pluginRepositories>
<pluginRepository>
<id>smartbear-sweden-plugin-repository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
For this example, I have added it to my POM.xml; however ideally you should add these repositories in settings.xml.
Step3: Create POM.xml for SOAPUI project:
Below is the sample POM.xml for my SOAPUI project.
<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>
<name>Enterprise Quote Clearance</name>
<groupId>com.esb.soapui</groupId>
<artifactId>EnterpriseQClearance</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Enterprise Quote Clearance</description>
<pluginRepositories>
<pluginRepository>
<id>smartbear-sweden-plugin-repository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>4.6.1</version>
<executions>
<execution>
<id>QClearanceTest</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<projectFile>C:\Anand\DevOps\QClearance\src\test\soapui\EnterpriseClearanceService-soapui-project.xml</projectFile>
<testSuite>TestSuite 1</testSuite>
<testCase>DCItems</testCase>
<endpoint>http://esbserver.com:7800/EntClearanceService/EnterpriseClearanceService</endpoint>
<outputFolder>${project.build.directory}/surefire-reports</outputFolder>
<junitReport>true</junitReport>
<printReport>false</printReport>
<projectProperties>
<projectProperty>NameInsured=IBM</projectProperty>
</projectProperties>
<settingsFile>C:\Anand\DevOps\QClearance\src\test\soapui\soapui-settings.xml</settingsFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
You need to update the values for elements in 'Configuration' per your project. If you want to execute all the Test cases inside a Test Suit, simple 'testCase' element. Similarly if you want to execute all the Test Suites in the project, simly remove testSuit element as well.
Note that I have supplied the value for 'projectProperty' (NameInsured=IBM) that we had set in soapui project.
Note the element 'settingsFile'. We can use this file to configure the SOAPUI properties for my test. Here I am overwriting socket timeout to 200 seconds using 'soapui-settings.xml'. Give the absolute path for this file.
Below is the content of 'soapui-settings.xml':
<con:soapui-settings xmlns:con="http://eviware.com/soapui/config">
<con:setting id="HttpSettings@socket_timeout">200000</con:setting>
</con:soapui-settings>
Jenkins will use this timeout value. By default Jenkins uses 60 seconds socket timeout, so I have increased it to 200 seconds for requests that take long time to come back.
You can refer to smartbear website to get the information about the variables that you can set. You can configure those as per your requirement.
http://www.soapui.org/test-automation/maven/maven-2-x.html
Save the POM.xml at the same location where you saved the soapui project.
Step 4: Create Jenkins Job:
Click on New Item and select 'Maven project' and give it a name:
You can do Source control configuration; however for this example to keep it simple we will just use a local project.
In 'Build', supply absolute path for POM.xml of soapui project and provide goal & options. You can give custom workspace also for jenkins.
Save the Job.
Now you are all set to run SOAPUI test Jenkins job. I ran my test and got the below result:
Here I will take a simple example of Functional test; however you can scale it up for load test as well.
Environment:
SOAPUI 5.0.0 (free version)
Maven 3.3.3
Jenkins 1.633
If you want to know how to configure Maven and Jenkins, pls refer to my post :
http://anandawasthitech.blogspot.com/2015/10/iib-continuousintegration-maven-jenkins.html
Step1: Create SOAPUI Project:
Create a SOAPUI project and create a Test Suit. Add a Test case in this Test Suit. You can configure project properties to pass the values dynamically in your request. You can pass the property value using the syntax "${#Project#PropertyName}" See the below example:
Click on the project and click on '+' button under 'Custom Properties'. Add a property name and value. In the soap request, supply this property. Refer to below screen-shot:
Further you can set assertions to validate the response. All this depends on your requirement, you can configure it accordingly.
Let us save the soapui project.
Step2: Update Maven settings.xml:
Add below plugin repository in settings.xml for Maven:
<pluginRepositories>
<pluginRepository>
<id>smartbear-sweden-plugin-repository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
For this example, I have added it to my POM.xml; however ideally you should add these repositories in settings.xml.
Step3: Create POM.xml for SOAPUI project:
Below is the sample POM.xml for my SOAPUI project.
<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>
<name>Enterprise Quote Clearance</name>
<groupId>com.esb.soapui</groupId>
<artifactId>EnterpriseQClearance</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Enterprise Quote Clearance</description>
<pluginRepositories>
<pluginRepository>
<id>smartbear-sweden-plugin-repository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>4.6.1</version>
<executions>
<execution>
<id>QClearanceTest</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<projectFile>C:\Anand\DevOps\QClearance\src\test\soapui\EnterpriseClearanceService-soapui-project.xml</projectFile>
<testSuite>TestSuite 1</testSuite>
<testCase>DCItems</testCase>
<endpoint>http://esbserver.com:7800/EntClearanceService/EnterpriseClearanceService</endpoint>
<outputFolder>${project.build.directory}/surefire-reports</outputFolder>
<junitReport>true</junitReport>
<printReport>false</printReport>
<projectProperties>
<projectProperty>NameInsured=IBM</projectProperty>
</projectProperties>
<settingsFile>C:\Anand\DevOps\QClearance\src\test\soapui\soapui-settings.xml</settingsFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
You need to update the values for elements in 'Configuration' per your project. If you want to execute all the Test cases inside a Test Suit, simple 'testCase' element. Similarly if you want to execute all the Test Suites in the project, simly remove testSuit element as well.
Note that I have supplied the value for 'projectProperty' (NameInsured=IBM) that we had set in soapui project.
Note the element 'settingsFile'. We can use this file to configure the SOAPUI properties for my test. Here I am overwriting socket timeout to 200 seconds using 'soapui-settings.xml'. Give the absolute path for this file.
Below is the content of 'soapui-settings.xml':
<con:soapui-settings xmlns:con="http://eviware.com/soapui/config">
<con:setting id="HttpSettings@socket_timeout">200000</con:setting>
</con:soapui-settings>
Jenkins will use this timeout value. By default Jenkins uses 60 seconds socket timeout, so I have increased it to 200 seconds for requests that take long time to come back.
You can refer to smartbear website to get the information about the variables that you can set. You can configure those as per your requirement.
http://www.soapui.org/test-automation/maven/maven-2-x.html
Save the POM.xml at the same location where you saved the soapui project.
Step 4: Create Jenkins Job:
Click on New Item and select 'Maven project' and give it a name:
You can do Source control configuration; however for this example to keep it simple we will just use a local project.
In 'Build', supply absolute path for POM.xml of soapui project and provide goal & options. You can give custom workspace also for jenkins.
Save the Job.
Now you are all set to run SOAPUI test Jenkins job. I ran my test and got the below result:
Started by user anonymous Building in workspace C:\Anand\DevOps\QClearance\src\test\soapui Parsing POMs Established TCP socket on 50629 [soapui] $ "C:\Program Files\Java\jdk1.7.0_79/bin/java" -Xms1024m -Xmx4096m -XX:PermSize=1024m -cp "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven32-agent-1.7.jar;C:\Anand\DevOps\apache-maven-3.3.3\boot\plexus-classworlds-2.5.2.jar;C:\Anand\DevOps\apache-maven-3.3.3/conf/logging" jenkins.maven3.agent.Maven32Main C:\Anand\DevOps\apache-maven-3.3.3 "C:\Program Files (x86)\Jenkins\war\WEB-INF\lib\remoting-2.52.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven32-interceptor-1.7.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.7.jar" 50629 <===[JENKINS REMOTING CAPACITY]===>channel started Executing Maven: -B -f C:\Anand\DevOps\QClearance\src\test\soapui\pom.xml -s C:\Anand\DevOps\apache-maven-3.3.3\conf\settings.xml -gs C:\Anand\DevOps\apache-maven-3.3.3\conf\settings.xml clean test [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Enterprise Quote Clearance 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ EnterpriseQClearance --- [INFO] Deleting C:\Anand\DevOps\QClearance\src\test\soapui\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ EnterpriseQClearance --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory C:\Anand\DevOps\QClearance\src\test\soapui\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ EnterpriseQClearance --- [INFO] No sources to compile [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ EnterpriseQClearance --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory C:\Anand\DevOps\QClearance\src\test\soapui\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ EnterpriseQClearance --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ EnterpriseQClearance --- [INFO] No tests to run. [JENKINS] Recording test results [INFO] [INFO] --- soapui-maven-plugin:4.6.1:test (QClearanceTest) @ EnterpriseQClearance --- SoapUI 4.6.1 Maven2 TestCase Runner 06:54:11,965 WARN [SoapUI] Missing folder [C:\Anand\DevOps\QClearance\src\test\soapui\.\ext] for external libraries 06:54:12,461 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Anand\DevOps\QClearance\src\test\soapui\soapui-settings.xml] 06:54:13,913 INFO [WsdlProject] Loaded project from [file:/C:/Anand/DevOps/QClearance/src/test/soapui/EnterpriseClearanceService-soapui-project.xml] 06:54:13,914 WARN [WsdlProject] Project 'EnterpriseClearanceService' is from a newer version (5.0.0) of SoapUI than this (4.6.1) and parts of it may be incompatible or incorrect. Saving this project with this version of SoapUI may cause it to function differently. 06:54:14,613 INFO [SoapUITestCaseRunner] Setting project property [NameInsured] to [IBM] 06:54:14,638 INFO [SoapUITestCaseRunner] Running SoapUI tests in project [EnterpriseClearanceService] 06:54:14,639 INFO [SoapUITestCaseRunner] Running TestCase [DCItems] 06:54:14,713 INFO [SoapUITestCaseRunner] Running SoapUI testcase [DCItems] 06:54:14,738 INFO [SoapUITestCaseRunner] running step [GetDCItemsForClearance - Request 1] 06:54:15,291 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request 06:54:15,292 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: POST /EntClearanceService/EnterpriseClearanceService HTTP/1.1 06:55:18,840 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK 06:55:18,850 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely 06:55:20,154 INFO [SoapUITestCaseRunner] Assertion [SOAP Response] has status VALID 06:55:20,155 INFO [SoapUITestCaseRunner] Assertion [Not SOAP Fault] has status VALID 06:55:20,158 INFO [SoapUITestCaseRunner] Finished running SoapUI testcase [DCItems], time taken: 65403ms, status: FINISHED 06:55:20,159 INFO [SoapUITestCaseRunner] TestCase [DCItems] finished with status [FINISHED] in 65403ms [JENKINS] Recording test results [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:17 min [INFO] Finished at: 2015-10-14T06:55:23-04:00 [INFO] Final Memory: 27M/982M [INFO] ------------------------------------------------------------------------ [JENKINS] Archiving C:\Anand\DevOps\QClearance\src\test\soapui\pom.xml to com.endur.esb.soapui/EnterpriseQClearance/1.0-SNAPSHOT/EnterpriseQClearance-1.0-SNAPSHOT.pom channel stopped Finished: SUCCESS