Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Jmeter Interface Test-assertion

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report