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.
    enter-api-server-details-jmeter
  • Next, add JSON Assertion to the HTTP Request(Right-click on HTTP Request-->Add-->Assertions-->JSON Assertion)
    add-json-assertion-to-request-jmeter
  • Select Additionally Asset value option and enter $. in the Assert Json Path Exists.
    enter-dollar-and-select-additionally-assert-value-jmter
  • 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.
    http-request-under-json-jmeter
  • If you go and check the response data, you will find all the product details.
    response-data-with-product-details-jmeter
  • 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.
    select-json-test-path-tester-jmeter
  • 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.
    enetr-copied-details-in-json-assertion-jmeter
  • Save and run the thread Group, After the Execution, the Assertion Result will be as follow. that means the JSon Assertion is working well.
    assertion-result-jmeter-json
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions