Table of content

JSON Assertion in JMeter

JSON path Assertion in jmeter, the assertion is checked or test a statement or condition and the result will be true or false. ... JSON path assertion is one of the kind assertions it will use when we are getting JSON response it will have mostly when we test rest API.

The Following Example Demonstrates the JSON Assertion
  • Open the JMeter and then add Thread Group to the Test Plan.
  • Next add HTTP Sampler to the Thread Group(Right-click on Thread Group-->Add-->Sampler-->HTTP Request)
  • And then, enter the server address and path details as below.
  • Next, add JSON Assertion to the HTTP Request(Right-click on HTTP Request-->Add-->Assertions-->JSON Assertion)
  • Select Additionally Asset value option and enter $. in the Assert Json Path Exists.
  • Add View Result Tree to the HTTP request and then save and run the thread group. The HTTP Request has not passed but still, it is showing the response details.
  • If you go and check the response data, you will find all the product details.
  • In the View Result Tree, select the JSON Path Tester, and Enter Records in the JSON Path Expression and then click on the Test button, it will show you all the details.
  • Copy the Result details and then go to the JSON Assertion and paste it in the Expected value and then enter $.records and then run the thread group.
  • Save and run the thread Group, After the Execution, the Assertion Result will be as follow. that means the JSon Assertion is working well.
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions