XML Assertions in Jmeter

Before going through this tutorial please have a brief idea about XML.

The XML Assertion tests the response data whether it consists of a formally correct XML document.So it validates the response to be a valid XML type.It does not validate the XML based on a DTD or schema.To validate the response against any schema you can use XML Schema Assertions.

To use XML Assertions we have to record the XML file from the server.In this example we will be recording these files:

1. Correct XML document
2. Invalid XML document

File1:Valid File4:Invalid
<?xml version=”1.0″?>
<?xml version=”1.0″?>
<body>Call me today.<body>


1. Record file1 (Valid XML) and file4 (invalid XML) from this link: http://www.alokranjan.uuuq.com.Or you can can record any file of your own choice.xmlassn1

Now add XML assertions to both the sample. (Add->assertions->XML assertions).also add a View Results tree Listener. Now run the script. The result in listener will look like this.The failure is shown in red.

The Assertion result is like this.

Error on line 7: The element type “body” must be terminated by the matching end-tag “</body>”.

To view the assertion results we can add an assertions results listener. (Add->Listener->assertions results)

If you try to assert the response of any normal html request with XML assertions it will though a mark up error,like this:

The markup in the document preceding the root element must be well formed.


One Response

  1. […] can also go through the previous tutorial: xml assertions […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: