Rock
Rock

Reputation: 159

additional "/" (slash) from response assertion is showing in Jmeter

I want to use response assertion to match the response from server, here when I am getting responses it shows like { "per_page": 6, "total": 12, "data": [ { "last_name": "Lawson", "id": 7, "avatar": "https://reqres.in/img/faces/7-image.jpg", "first_name": "Michael", "email": "[email protected]" },

But in response assertion it showing like Assertion failure message:Test failed: text expected to contain /{ "per_page": 6, "total": 12, "data": [ { "last_name": "Lawson", "id": 7, "avatar": "https://reqres.in/img/faces/7-image.jpg", "first_name": "Michael", "email": "[email protected]" }, { and therefor it gets failing even though its matching but due to addition / (slash), its getting failed.

enter image description here enter image description here

Upvotes: 0

Views: 370

Answers (2)

debasis pattnayak
debasis pattnayak

Reputation: 1

I have also faced same problem. But this assertion not trimming your response. So check you have additional space or line at the end of actual response end. If you give the addition space or line it will pass.

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168092

JMeter doesn't "add" slashes anywhere, it's just a matter of visualization, you're getting your pattern surrounded with slashes as there is a mismatch, basically JMeter fails to find what you put in the "Patterns to test" in the application response

Demo:

enter image description here

See lines 472 and 480 in the ResponseAssertion source

So make sure that your response contains the pattern and be aware that every line brake or empty space matters so if your server returns non-formatted string and you're expecting a "pretty" one - the assertion will fail.

We cannot suggest the best option without seeing you actual response, however full-text comparing 2 JSON entities doesn't seem a good approach to me in terms of robustness and reliability, you might want to consider JSON Assertion or JSON JMESPath Assertion instead

Upvotes: 0

Related Questions