How to test that server returns 401

青春壹個敷衍的年華 提交于 2021-01-29 06:05:03

问题


I want to create a jmeter test which should pass if the server returns 401. I also want to test that the message body contains a json.

I have done this so far

But the test case is failing. Why?

UPDATE I thought I should use ignore status in response assertion but then the test color comes up as both green and red if the json body doesn't match. I am confused what is happening and whether the test has passed or not.


回答1:


It seems I was doing several things wrong.

  1. First, the assertions should have been children of the request.
  2. The response assertion should check response code as 401 but ignore status should also be checked otherwise jmeter interprets the message as error

"Ignore Status : Checking this checkbox tells JMeter to not mark in error a page that returns a response code that it considers in error (Anything different from 2XX, 3XX). This is useful when you know a request should fail in a certain way and you want to check it does"



来源:https://stackoverflow.com/questions/65042641/how-to-test-that-server-returns-401

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