Home > other >  Jmeter notes: response to assert that explanation
Jmeter notes: response to assert that explanation

Time:09-22


: Jmeter notes: response assertions, rounding

At ordinary times we use jmeter performance testing, often use assertions, jmeter provides a lot of kinds of assertion, originally want to write all the, but found that every assertion of contents a lot, so I write you what we often use the response of the assertion,

On cnblog writing for the first time, not layout, hope talent show, if reproduced, please indicate the source



Response asserts that assertion checking on the server's response

(1) the scope of application: the main sample and sub sample, the main sample only, sub - sample only, jmeter variable

About the range of application, most of us check the "main sample only" is enough, because we have a request, essentially only one request, but when we send a request, can trigger multiple server requests, similar to ajax, then there is the main sample and sub - of sample points,

In addition, for a redirect requests, and check the "follow the redirect", then the two requests are sub - sample, after the redirection request (the second request) is the main - sample

About the main sample and sub sample, interested can look at this post

http://stackoverflow.com/questions/28214936/jmeter-in-which-scenario-i-can-use-main-sample-or-sub-sample-or-both-for-te



(2) Response fields: Response Text, the Document (Text), url sample, the Response code, Response, the Response headers, and ignore the status

The response text: the server response text, generally normal HTTP response, check this,

All Document (Text) : Apache Tika support server response, including Text response, also support the PDF, Microsoft Office, Audio and Video formats, with Apache jmeter Tika to parse the content server response, will be very memory consumption, but also easy to parse failed, so generally normal HTTP request, don't choose this,

Sample: url is the url of the sample asserted that if the request is not redirected (302), then this is the request url, if there is a redirect (and follow the redirect), then the url contains the request url and redirect url

Response code: HTTP response code, such as 101200302404501, but when we want to verify the HTTP response code such as 404501, need to check the "ignore the status", because when the HTTP response code of 400500, jmeter default this request failed,

Response: the HTTP response code corresponding response information, such as: OK, Found

HTTP/1.1 200 Ok

HTTP/1.1 302 Found

The Response headers: Response Header information, such as

Server: Tengine
Date: Thu, 12 Mar 2015 09:43:52 GMT
The content-type: text/HTML
The Content - Length: 260
Connection: close
Location: http://www.baidu.com/404.html



(3) pattern matching rules

Including: return results including you specify the content of the support for regular matching

For example:

Response field is: response text

Matching pattern matching rules:

Assertion is: 1, 2, invalid [a-z] +

When the return value is: {" MSG ":" the channel invalid. "}, the two assertions are ok, return true



Matching:

(1) equivalent of equals, when the return value is fixed, can do return value assertion, the effect is the same as the equals

(2) regular match, with a regular expression match returns results, but must all match, the regular expression must be able to match the return value, not part of the return value,

For example:

Response field is: response text

Matching pattern matching rules:

Assertion is: 1, {" MSG ":" the channel invalid. "} 2, \ {" MSG ":" [a-z] + invalid \. "\}, 3, [a-z] +



When the return value is: {" MSG ":" the channel invalid. "}, alleging 1 2 is ok, 3 is false

When the return value is: {" MSG ":" the channel invalid. "}, assert that 1 3 is false, the assertion that 2 is ok,

Reason for this is that assertion can only be used for 1 equals, and assert that part 3 matches only the return value, but not all match,



Equals: return results in complete accord with assertions you specify

SubString: the same way as "include", refers to the return results including you specify the content, but the SubString does not support a regular string

For example:

Response field is: response text

Matching pattern matching rules:

Assertion is: 1, 2, invalid [a-z] +

When the return value is: {" MSG ":" the channel invalid. "}, 1 returns true assertions, but asserts that 2 returns false



No: is equivalent to invert the above, if the result is true, check "no", after the final assertion results to false, if the above assertion results to false, tick "no", after the final assertion results to true,

CodePudding user response:

https://edu.csdn.net/course/detail/22948

CodePudding user response:

[face] qq: 79. GIF [/face
  • Related