Adding / at the start and end of the asserted string in Response Assertion in JMeter

心不动则不痛 提交于 2019-12-14 03:20:38

问题


Assert given value:

"action":"GET /api/invoice_status","description":"[NO_AUTH] get invoice statuses"

Assertion failure message:

Test failed: text expected to contain /"action":"GET /api/invoice_status","description":"[NO_AUTH] get invoice statuses"/


回答1:


It is adding / slashes just to represent properly but it's not an issue. Cross verify your response after running the script, there might be some difference in the response and the text which you are passing in assertion. Also, there is no need to pass complete response in assertion, just pass some important text like success, passed (if present in response) or any other text available in your response and click on contains radio button inside Response assertion




回答2:


Got the solution by using the \ forward slash escape character.




回答3:


As per How to Use JMeter Assertions in Three Easy Steps

The Pattern can be either be:

a “string” for “Equals” or “Substring” clauses

a “Perl5-style” Regular Expression for “Contains” or “Matches” clauses

So if you choose "Contains" mode - JMeter treats pattern as Regular Expression. Either escape meta characters with a backslash - \ or consider switching the Response Assertion into "Substring" mode instear.



来源:https://stackoverflow.com/questions/36126447/adding-at-the-start-and-end-of-the-asserted-string-in-response-assertion-in-jm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!