Course
JMeter Tutorial for Beginners: Learn in 7 Days
JMeter Training Summary Apache Jmeter is a popular open-source performance testing tool. This...
Assertion help verifies that your server under test returns the expected results.
Following are some commonly used Assertion in JMeter:
The response assertion lets you add pattern strings to be compared against various fields of the server response.
For example, you send a user request to the website http://www.google.com and get the server response. You can use Response Assertion to verify if the server response contains expected pattern string (e.g. "OK").
The Duration Assertion tests that each server response was received within a given amount of time. Any response that takes longer than the given number of milliseconds (specified by the user) is marked as a failed response.
For example, a user request is sent to www.google.com by JMeter and get a response within expected time 5 ms then Test Case pass, else, test case failed.
The Size Assertion tests that each server response contains the expected number of byte in it. You can specify that the size be equal to, greater than, less than, or not equal to a given number of bytes.
JMeter sends a user request to www.google.com and gets response packet with size less than expected byte 5000 bytes a test case pass. If else, test case failed.
The XML Assertion tests that the response data consists of a formally correct XML document.
The HTML Assertion allows the user to check the HTML syntax of the response data. It means the response data must be met the HTML syntax.
We will continue on the script we developed in the earlier tutorial.
In this test, we are using Response Assertion to compare the response packet from www.google.com matches your expected string.
Here is the roadmap for this test:
The response assertion control panel lets you add pattern strings to be compared against various fields of the response.
Right-Click Thread Group -> Add -> Assertions -> Response Assertion
Response Assertion Pane displays as below figure:
When you send a request to Google server, it may return some response code as below:
Assume that you want to verify that the web server google.com responses code contains pattern 302,
On Response Field To Test, choose Response Code,
On Response Assertion Panel, click Add -> a new blank entry display -> enter 302 in Pattern to Test.
Right click Thread Group, Add -> Listener -> Assertion Results
Click on Thread Group -> Assertion Result
When you ready to run a test, click the Run button on the menu bar, or short key Ctrl+R.
The test result will display on the Assertion Results pane. If Google server response code contains the pattern 302, the test case is passed. You will see the message displayed as follows:
Now back to the Response Assertion Panel, you change the Pattern to test to from 302 to 500.
Because Google server response code doesn't contain this pattern, you will see the test case Failed as following:
If you face the issue while running the above scenarios ... do the following:
JMeter Training Summary Apache Jmeter is a popular open-source performance testing tool. This...
As soon as you launch JMeter, you will see 2 elements Test Plan Workbench {loadposition...
A processor is used to modify the Samplers in their scope. There are 2 Types of processors:...
{loadposition top-ads-automation-testing-tools} JMeter is an open source load and performance...
Record Testing help tester to record & run their activity against test target. It is a type of...
JMeter Load Testing JMeter Load Testing is a testing process done using a load testing tool named...