当前位置:网站首页>Explanation of assertions in JMeter

Explanation of assertions in JMeter

2022-06-25 08:56:00 fish_ study_ csdn

One 、JMeter Assertion

1.1 The concept of assertion

Assertion : Let the program judge whether the expected results are consistent with the world results

Tips :JMeter Assertion is to add a layer of judgment mechanism at the return level of the request : Because the request was successful , It doesn't mean the results are right , Therefore, detection mechanism is needed to improve the accuracy of testing

1.2 JMeter Common assertions in

(1) Response assertion

(2)JSON Assertion

(3) Duration assertion (Duration Assertion)

Two 、 Response assertion

How to add : test plan --> Thread group -->HTTP request -->( Right click to add ) Assertion --> Response assertion

To configure :

(1) Test fields : Fields to check

2) Pattern matching rules : What rules need to be used to check : Regular 、 And 、 or 、 Not 、 be equal to

Test fields
The response text   Keywords in the response body
Response code   Response code ,200
Response information   The information returned after the response code ,OK
Response Headers  When testing the protocol, use , This is not used by general testing businesses
Request Headers    
URL sample Content sent out , Generally, it is not checked , It all depends on the content of the response
Document(text)   Check text Formatted text
Ignore Status   Test the abnormal scenario , Determine the state of the wrong response , The result is not marked red
Request Data    

Include

Regular
matching Regular
be equal to Equals
contain Substring no 、 perhaps 、 And

(3) Test mode : Value to be verified , You can fill in multiple values for comparison

Such as : request :https://www.baidu.com

Check : Let the program check whether the response data contains “ Baidu once , You will know ”

Operation steps :

(1) Add thread group

(2) add to HTTP request

(3) Add response assertion :HTTP request --> add to --> Assertion --> Response assertion   

 (4) Add assertion results : Thread group --> add to --> Monitor --> assertion results   

(5) Add view result tree

 

3、 ... and 、JSON Assertion

        This component is used to JSON Document validation , The verification steps are as follows :

        1. First analysis JSON data , If the data is not JSON, The verification fails

        2. Use Jayway JsonPath 1.2.0 Search the specified path using the syntax in . If you can't find the path , Will fail

        3. If found in the document JSON route , And it is required to verify the expected value , Then it will perform the verification operation

        Mode of operation : test plan --> Thread group -->HTTP request -->( Right click to add ) Assertion -->JSON Assertion

  Operation steps

        1. Add thread group

        2. add to HTTP request     

       3. add to JSON Assertion

        Apply to HTTP The response is a JSON Format

        To configure :

                (1)JSON PATH:$.msg

                (2) Check “Additional assert value”

                (3)expected value Fill in The query is successful

 

  4. Add assertion results

5. Add view result tree ( A mistake and a success )

 

原网站

版权声明
本文为[fish_ study_ csdn]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250808335779.html