In our previous article, How to Test Soap Services with JMeter, we explained the basics of SOAP testing. If you have practiced this example, you are right now able to perform load testing on your applications. In this article, we’ll show you how you can verify the result of your response.
Assertions in JMeter are very strong. By using the assertions, you will be able to verify the stability of your application under heavy load. There are two options to make a validation:
- Response Assertion
- XPath Assertion
It requires you to specify “Field to Test” and “Pattern matching Rules”. By setting these two values, you will be able to verify your expected result. Let’s take a look at the most used ones.
- Text Response: This option lets you search for a string in the whole response. You can use “Contains”, “Matches” etc. patterns. But it’s not always a good approach to use this assertion type. The reason for that is; your response might also exist in another attribute of the XML message as you might have hundreds of attributes in your XML response.
- Response Code: This assertion is a good approach to verify the status of your application as there’s no verification on the test data. You will be able to monitor the state of your application, nothing more. You can check a different kind of HTTP status on this page: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
- Document(Text): This one is using the same approach as Text Response.
- Request Data: This one is checking if your request is valid according to the pattern you choose.
All these approaches might be a good approach but there are some flaws. That’s why we suggest you to use XPath Assertion for a stable performance testing script.
In XPath Assertion, there’s one configuration you should make. This is XML parsing Options.
- Use Tidy: This option should be checked in case you make an assertion on pure XML document which has a different structure than an XHTML file. If the response is an XHTML document, you might need to uncheck this option for proper parsing.
When you uncheck “Use Tidy”, you will have 4 other configuration elements. Most commons are below:
- Validate XML: This option checks the structure of response and validates its schema. This is a good approach to check the functionality of your response.
- Ignore Whitespace: Whitespace is always a pain during parsing or regular expression on a data. So this option will remove all the whitespaces for you. It will save your time.
Then you need to provide a valid XPath Expression for your test.
Besides those verifications, we always recommend you to use “Duration Assertion” to watch over your KPIs. Even if all your assertions work properly, you might have a performance problem on your service under heavy load. By using the duration assertion, you will be able to set a threshold to your request and monitor its performance.
Right now we are able to verify the state of your SOAP services from functional and non-functional view.