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
http://gilletterazor.blog126.fc2.com
http://poloclothing.blogsome.com
http://venuschinawholesale.easyjournal.com
http://pumaspeedcat.blogharbor.com