In response performance testing -JMeter assertion assertion of said fine

Sampler for assertion verification result whether the corresponding request or response data returned desired. Verify that the test can be expected as a method.

For interface testing, is to test Request / Response, Request for a claim that may be, can also be carried out for Response. But most of the Response to do is assert.

JMeter elements common assertion follows:
1. The response to the assertion

2.JSON Assertion

This chapter, we learn JMeter first major response to the assertion.

Configuration Item

Apply to:

1. In most cases, only the primary sampler has all the necessary data in response. However, many Web applications using Ajax, JQuery technology, a single request may generate a plurality of internal sub-requests, and each request has a corresponding response data.

For example, a request for a page, the page where the js call other requests.

"Embedded Resources from HTMLFiles" item in the Advanced Settings 2. HTTP requests, check the "Retrieve All Embedded Resources", when sending the request, parses the associated embedded resources, will lead to the sampler may have multiple sub-sampler .

Embedded resources include: images, applets, stylesheets, external

scripts、frames/iframes、

background images、background sound等。

3. There are redirected request, and check the "Follow Redirects", the main sampler finally returns the URL of the request,

The first URL and redirect all URL request for the return of the sub-sampler.

For example, using http://www.sina.com/ access Sina, there will be twice redirection:

The first request: GET http://www.sina.com/ redirect Returns:

Location: http://www.sina.com.cn/

Second request: GET http://www.sina.com.cn/ redirected back to

Back: the Location: https://www.sina.com.cn/

Third request: GET https://www.sina.com.cn/

Master sampler for the third request; the first, second and third sub-sampler request.

Main sample and sub-samples

Include main samples with all the sub-sampler

Main sample only

It is limited to the primary sampler

Sub-samples only

Scope is limited to all sub-sampler

JMeter Variable Name to use

Range of variables including JMeter

Field to Test:
1.Text Response

The response body. For the HTTP protocol, it is the response message-body (not including the header field and the status line)

2.Response Code

Response code. For the HTTP protocol, it is the response status code, and the like such as 200,304,404.

3.Response Message

Response message. For the HTTP protocol, it is the reason the phrase, such as OK, Not Modified, Not Found and so on.

4.Response Headers

In response header field.

5.Request Headers

Request header fields.

6.URL Sampled

URL request. For HTTP requests, check if the "Follow Redirects", URL redirection after contains.

7.Document(text)

Extract text from all types of documents by Apache Tika. This option turns will seriously affect performance, be used with caution.

8.Request Data

Request data. For the HTTP protocol, the request is a message-body (not including the request line and header field)

9.Ignore Status

By the result of conventional asserted in response to a state combined to determine the overall success of the sampler.

Ignore Status check box is selected when the calculated force before assertion response status is successful.

In return HTTP protocol 4xx and 5xx status codes default is unsuccessful, check this success can be used to set the state before executing further examination.

Please note that this will have the effect of clearing any previous assertion failure, so make sure to only turn this setting on the first assertion.

Pattern Matching Rules:

1.Contains

If the text contains a regular expression pattern that is true

2.Matches

If the entire text matches the regular expression pattern that is true

3.Equals

If the mode is equal to the entire text string (case sensitive), is true

4.Substring

If the text contains pattern string (case sensitive), is true

note:

Contains Matches mode and supports Perl5 style regular expressions;

Equals Substring mode and text string, does not support regular expressions.

5.Not

The results were negative assertions.

6.Or

A plurality of logic test mode "or" combination.

Patterns to Test:

For a list of test mode. Each model is individually tested. If the failure mode, the other mode is not checked, the use of a plurality of patterns provided for each assertion using no distinction between a plurality of mode settings asserted (assuming the same other options).

Custom failure message:

Custom assertion failure information. That set the value "Assertion failure message" of.

To make the assertion request

1. asserts the request header field

In "To test the response field" Select "Request Headers"

2. The assertion request URL address

Discuss two cases:

1) If you check "Follow Redirects" the "HTTP Request", then the assertion object contains the request URL, and redirect Location URL returned headers, if redirected more than once, each containing the URL returned;

2) If the "HTTP Request" no check "Follow Redirects", it asserts that the object is only a request for a URL.

In response to the assertion made

1. assertion response header field

In the "Field to Test" Select "Response Headers"

2. The response status codes assertion

In the "Field to Test" Select "Response code"

3. The response asserts reason phrase

In the "Field to Test" Select "Response Message"

Assert response body

In the "Field to Test" select "Text Response"

Multi-mode assertion

In "Patterns to Test" item you can add more assertions test mode, a plurality of patterns may be used, "and", "or" and "not" logic combination:

1. The logic (and)

Among a plurality of default mode "and (and)" logically combining

2. The logical OR (or)

When the check between "Pattern Matching Rules" in the "Or", the multiple mode "or (or)" logically combining

3. The logical negation (not)

When checked "Pattern Matching Rules" in the "Not", then the Not In each mode "and" or "or" combination

Suppose there are patterns p1, p2, p3, ..., pn (priority not> and> or)

1) Check only "Not"

It is equivalent to: (not p1) and (not p2) and (not p3) and

.. and (not pn)

2) Check the "Not" and "Or"

相当于:(not p1) or (not p2) or (not p3) or ...

or (not pn)

Guess you like

Origin blog.51cto.com/14645850/2464020