How to use assertions in JMeter SOAP/XML-RPC sampler

Assertions are essential components in a JMeter test plan. They are very important in regression testing in which you can compare test results with a pre-defined output. 
As I explained here, JMeter Soap/xml-rpc request sampler can be considered as an one of the easiest mechanisms to test web services. 
Lets see how assertions can be added to a Soap/xml-rpc sampler so that you can use it easily in automated web services regression testing.

Before continue with this, you may go through  the following articles.

Step 1
In this example we are going to invoke the sample version service that ships with Apache Axis2.
Therefore, please download Apache Axis2-1.4.1 binary distribution from here and extract it in your file system.

Start Axis2server by runnning axis2server.bat{sh}

Step 2
Start JMeter by running jmeter.bat or sh.
Right click on Test Plan element and add a thread group.
Then add the SOAP/XML-RPC Request sampler element to the above thread group. 
(Add --> Sampler --> SOAP/XML-RPC Request)

Paste the following soap request in the Soap/XML-RPC Data section in the sampler.

<?xml version='1.0' encoding='UTF-8'?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Body>
       <ns0:getVersion xmlns:ns0="http://axisversion.sample"/>
      </soapenv:Body>
   </soapenv:Envelope>

Enter "http://localhost:8080/axis2/services/Version" as the URL.
Enter "urn:getVersion" for "Send SOAPAction".

Step3

Right click on the SOAP/XML-RPC Request sampler element and Add --> Assertions --> Response Assertion

Enter a suitable name for the assertion. 
Enter "Hello I am Axis2 version service" as the pattern to test.
Select "Text Response" as Response Field to Test.
Select "Contains" as the pattern matching rule. 



Step 4
Now we need to visualize the result of this assertion. Therefore right click on the Thread Group element and Add --> Listener --> Assertion Results

Run the thread group. If test is successful, you will not get any errors in Assertion Results. 
Change the pattern matching rule of the assertion in to "Matches" and run the test again.

You will see the failed assertion in assertion results view.


You can extend this test with more complex web services and add assertions accordingly. Then this can be executed in regression testing of your web services. 

Comments

Anonymous said…
God bless you!I really agree with your opinions.Also,there are some new fashion things here,gillette razor blades.gillette mach3 razor bladesfor men.As for ladies,gillette venus razor blades must the best gift for you in summer,gillette fusion blades are all the best choice for you.
http://gilletterazor.blog126.fc2.com
http://poloclothing.blogsome.com
http://venuschinawholesale.easyjournal.com
http://pumaspeedcat.blogharbor.com

Popular posts from this blog

Common mistakes to avoid in WSO2 ESB - 1 - "org.apache.axis2.AxisFault: The system cannot infer the transport information from the URL"

Working with HTTP multipart requests in soapUI

WS-Reliable messaging with WSO2 WSAS -1