Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Jmeter Interface Test-assertion

Shulou Source: shulou.com Published: 2022-06-03 07:11:36 09月26日 Update

JMeter interface test-assertion corresponds to qq group number: 616961231

When a http request is issued, how can you tell if it is executed correctly? By checking the server response data, whether it conforms to the expected data, if yes, the task succeeds, if not, the task fails.

There are many types of Jmeter assertions, so I'm not going to give examples here.

Add assertion mode, HTTP sampler right-> add-> assertion-> response assertion

Response assertion introduction:

1.Apply to

When we issue a request, which may trigger multiple requests on the server, main sample only is sufficient to cover.

two。 Response fields to test:

Response text: checking in Response data

Response Header: check in the response header

Url samples: verifying in url

3. Pattern matching rules

Contains: as long as the response data contains the response check field, it is judged to be successful

No: check whether or not the judgment statement returns false, which is used for non-existence judgment.

The accuracy of Equals judgment is relatively high.

4. The pattern to be tested

Check information

Response text assertion

Response head assertion

Url assertion

Size Assertion:

In response to the message body size, sometimes we add text assertions, such as code:0 is successful, but the json string in body has no data or is empty, which meets the expected requirements of the interface, so Size Assertion can check

Assertion duration

In milliseconds, the sampler of the result tree can see the time returned each time. Load time: 456 is the number of milliseconds consumed by the request.

The above assertions are configured and can be executed.

Then we modify the content of the assertion to determine whether the assertion really works.

Change the response text assertion to "code": 1

Response header assertion judgment changed to HTTP/1.1 201

Url assertion changed to username=admin

Assertion duration changed to 300 milliseconds

Change the size of Size Assertion to 300

Then execute it again.

As you can see, all assertions are checked in strict accordance with the setting and do not pass.

So much for the assertion, so come and learn.

Today's recommended reading articles are recommended

JMeter database operation

Jmeter Interface Test-regular expression

JMeter returns garbled code in Chinese

Jmeter interface testing-parameterization

JMeter Interface testing-Basics

Test-impression

Add Wechat to the consulting work

scan a QR code

Welcome self-recommendation and recommendation, need Wechat to push resume!

Please poke the QR code below to learn more.

Tags: Test data interface text time success recommendation check lieutenant colonel task size field mode 2D QR code service next strictly follow garbled function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information OPPO Reno Apple NVidia