问题
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.
- First, the assertions should have been children of the request.
- The response assertion should check response code as
401butignore statusshould also be checked otherwisejmeterinterprets 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