The latest and most comprehensive Jmeter interface test on the entire network: response assertion element

Introduction to response assertion components:

  The function of the response assertion element is to perform automatic assertion verification on the response information of the interface to determine whether the interface return value obtained by the interface test is correct. This element in jmeter supports comparing various fields of the request or response with the pattern string. With this component, automated interface testing can be completed without the need to manually check the results returned by the interface.

Path:Right-click http request - assertion - response assertion

Shown below:

 Introduction to response assertion component fields:

Name/Comment:Custom descriptive text

APPly to: ​action function

  Main sample and sub-samples: Sampler acting on the main node and the sampler corresponding to the sub-node

  Main sample only:Sample that only acts on the main node

  Sub-samples only: Sampler that only acts on sub-nodes

  JMeter Variable Name to use: Acts on jmeter variables (the variable name of jmeter can be entered in the input box), extracting the required value from the specified variable value

Test field:The response field selection to be asserted supports request information, response information, etc., where the response text represents text extracted from various types of documents through Apache Tika< /span>

Ignore state:The overall success of the sampler depends on the assertion result combined with the existing response state, which is forced when the "Ignore state" checkbox is selected Success, then perform this assertion evaluation

    A request has multiple response assertions. When the first assertion sets this option, then if the first assertion fails and the second assertion succeeds, the transaction will still be in a successful state (the last assertion must be checked)

Pattern matching rules:

  1. Includes - true if the text contains a regular expression pattern

  2. Match - true if the entire text matches the regular expression pattern

  3. Equals - true if the entire text is equal to the pattern string (case sensitive)

  4. String (Substring) - true if the text contains the pattern string (case sensitive)

  5. No - Invert the check result to indicate that it does not contain, does not match, is not equal to, and does not have a Substring that matches the pattern string.

  6. Or - An assertion can add multiple "patterns to be tested". With the OR option, the assertion will succeed as long as one of the patterns matches. If "OR" is not selected, the AND option will be used by default. All patterns must match for the assertion to succeed.

Mode to be tested:Enter the expected result value, you can add multiple rows of expected results

Customized failure message:Set a custom assertion failure message to replace the system's default failure prompt message.


Practical examples:

Response text: Determine whether there is 7200 in the returned body; as shown below

Response code (response status code): Determine whether the response status code is 200; as shown below

Response information: Determine whether the response headers are OK; as shown below

Response header:Determine whether the information in the response headers contains the specified information; as shown below:

Request header: Determine whether the request header contains the specified information; as shown below

 URL sample: Determine whether there is specified information in the url; as shown below

 Recommended tutorials related to automated testing:

The latest automated testing self-study tutorial in 2023 is the most detailed tutorial for newbies to get started in 26 days. Currently, more than 300 people have joined major companies by studying this tutorial! ! _bilibili_bilibili

2023 latest collection of Python automated test development framework [full stack/practical/tutorial] collection essence, annual salary after learning 40W+_bilibili_bilibili

Recommended tutorials related to test development

The best in the entire network in 2023, the Byte test and development boss will give you on-site teaching and teach you to become a test and development engineer with an annual salary of one million from scratch_bilibili_bilibili

postman/jmeter/fiddler test tool tutorial recommendation

The most detailed collection of practical tutorials on JMeter interface testing/interface automated testing projects. A set of tutorials for learning jmeter interface testing is enough! ! _bilibili_bilibili

To teach yourself how to capture packets with fiddler in 2023, please be sure to watch the most detailed video tutorial on the Internet [How to Learn to Capture Packets with Fiddler in 1 Day]! ! _bilibili_bilibili

In 2023, the whole network will be honored. The most detailed practical teaching of Postman interface testing at Station B can be learned by novices_bilibili_bilibili

  Summarize:

 Optical theory is useless. You must learn to follow along and practice it in order to apply what you have learned to practice. At this time, you can learn from some practical cases.

If it is helpful to you, please like and save it to give the author an encouragement. It also makes it easier for you to search quickly next time.

If you don’t understand, please consult the small card below. The blogger also hopes to learn and improve with like-minded testers.

At the appropriate age, choose the appropriate position and try to give full play to your own advantages.

My path to automated test development is inseparable from plans at each stage, because I like planning and summarizing.

Test development video tutorials and study notes collection portal! !

Guess you like

Origin blog.csdn.net/m0_59868866/article/details/134736220