Jmeter Checkpoint/Assertion

Source: Internet
Author: User
Tags comparison


Purpose: To determine the information returned from the previous request, do string, packet size, html,xml, picture, etc. to ensure the accuracy of the returned information



Response assertions and persistent assertions should be used more, one test request returns the correct page, and the other tests the response time of the server.



How to use assertions:



Step_1: Add the corresponding assertion under the sampler of your choice (because different types of assertions check for different content). Configure the check content of the response (depending on the assertion, there is an assertion control panel that does not need to add anything, such as XML assertion).



Step_2: Add a listener for the assertion result (added from the listener), and through the assertion result you can see whether the assertion is passed. For a request, if passed, only the name of a row of requests will be printed in the assertion result, and if it fails, there will be a row failure in addition to the name of the request. (Different types of assertions, the results are different.) )



Note: A sampler can add multiple assertions, add assertions based on your inspection needs, and when all assertions are passed under sampler, the request succeeds.



Let's briefly say a few common assertions



1. Responseassertion (response assertion): Applies to content in the content returned by the end disk, the control Panel screenshot is as follows:






Position 1: Name, comment



Location 2: The appropriate field to test, that is, the item to be checked



Position 3: Pattern matching rules



Include: The return result includes the content you specified



Equls: The returned result is consistent with the specified result



Substring: A string that returns the result specified



No: Do not match



Position 4: The module to be tested, that is, fill in the results you specify, you can fill in more than one, as shown in the figure is that you want to return the text contains 2 specified string, only if it contains the 2 strings, this assertion is passed, otherwise, the calculation fails. ) button "Add", "delete" is the management of the specified content



2. Sizeassertion (Size Assertion): Used to determine the response time of the server, the Control Panel screenshot is as follows:






Position 1: Name, comment



Position 2: Specifies the size (in bytes) and the comparison type, returns the size of the content, the type of comparison, the size of the specified byte



The order in which the comparison is placed is: "The size of the returned content" "Comparison type" "Specifies the size of the byte" if the comparison is passed, then the assertion passes, as shown in figure,



If the size of the returned content is greater than 10 bytes, the assertion passes, otherwise it fails.






3. Durationassersion is used to determine the server response time, the control Panel screenshot is as follows:






Position 1: Name, comment



Position 2: Response time setting (in milliseconds), if the response time is greater than the set response time, the assertion fails, otherwise succeeds. (equal to the situation is not good set, I do not know how the situation)



4. HTML assertion (HTML assertion): Used to check the returned content, the format is consistent with the relevant standards in the specified format, see the following description






Position 1: Name, comment



Location 2:tidy Settings,doctype has auto, omit, strict, loose (here each setting represents what meaning is not very understanding)



Location 3: Format type, that is, you check the return content in that format, HTML or XHTML or XML.



Position 4: Acceptable maximum setting, error threshold: Maximum acceptable number of errors, Warning threshold: The maximum number of warnings that can be accepted. If you check "error only" This ignores warning, only the error is counted. If the result of the check for the returned content does not exceed the specified result, the assertion passes, otherwise it fails.









Supplement: Assertions can add multiple assertions together to judge, the assertion can also use the parameterized method, dynamic judgment.



Example: http://www.cnblogs.com/zhuque/archive/2012/11/14/2769562.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.