JMeter Performance Testing Tutorial 6 - What are Assertions and how to use them

Опубликовано: 14 Октябрь 2024
на канале: Testing Funda by Zeeshan Asghar
4,717
95

#jmeter #Jmeterscripts #assertions #performancetesting #stresstesting #loadtesting
What are Assertions in JMeter and how to use them with Real-time Examples?
---------------------------------------------------------------------------------------------------------------------
Assertions are used to perform additional checks on samplers and are processed after every sampler in the same scope. To ensure that an Assertion is applied only to a particular sampler, add it as a child of the sampler.

Assertions can be applied to either the main sample, the sub-samples, or both. The default is to apply the assertion to the main sample only.

If a sub-sampler fails and the main sample is successful, then the main sample will be set to failed status and an Assertion Result will be added. If the JMeter variable option is used, it is assumed to relate to the main sample, and any failure will be applied to the main sample only.

Response Assertion
The response assertion control panel lets you add pattern strings to be compared against various fields of the request or response. The pattern strings are:

Contains, Matches: Perl5-style regular expressions
Equals, Substring: plain text, case-sensitive
A summary of the pattern matching characters can be found at ORO Perl5 regular expressions.

You can also choose whether the strings will be expected to match the entire response, or if the response is only expected to contain the pattern. You can attach multiple assertions to any controller for additional flexibility.

Note that the pattern string should not include the enclosing delimiters, i.e. use Price: \d+ not /Price: \d+/.

By default, the pattern is in multi-line mode, which means that the "." meta-character does not match newline. In multi-line mode, "^" and "$" match the start or end of any line anywhere within the string - not just the start and end of the entire string. Note that \s does match new-line. Case is also significant. To override these settings, one can use the extended regular expression syntax. For example:

(?i)
ignore case
(?s)
treat target as single line, i.e. "." matches new-line
(?is)
both the above
These can be used anywhere within the expression and remain in effect until overridden. E.g.
(?i)apple(?-i) Pie
matches "ApPLe Pie", but not "ApPLe pIe"
(?s)Apple.+?Pie
matches Apple followed by Pie, which may be on a subsequent line.
Apple(?s).+?Pie
same as above, but it's probably clearer to use the (?s) at the start.

Duration Assertion
The Duration Assertion tests that each response was received within a given amount of time. Any response that takes longer than the given number of milliseconds (specified by the user) is marked as a failed response.

Size Assertion
The Size Assertion tests that each response contains the right number of bytes in it. You can specify that the size be equal to, greater than, less than, or not equal to a given number of bytes.

Subscribe our channel for latest videos
==================================
   / testingfunda  

#selenium #tutorials #free #2022 #training
Watch more free Selenium Tutorials
   • Selenium WebDriver with Java Tutorial...  

#JMeter #performance #testing #tutorials #free #2022 #training
Step by step free JMeter performance tutorials
   • Postman API Testing Tutorial for Begi...  

#postman #API #testing #tutorial #manual #automation #free #2022 #training
Step by step free postman API manual and Automation Testing tutorials
   • Postman API Testing Tutorials for Beg...  

#java #programming #tutorials #free #2022 #training
Step by step free Java programming tutorials
   • Java tutorial 1 - What is Java | How ...  

#cypress.io #automation #testing #tutorials #free #2022 #training
Step by step free cypress.io automation testing tutorials
   • Cypress tutorial 1 - What is Cypress ...  

#agile #Youtube #series #free #2022 #training
Learn about agile from free YouTube series
   • Agile  

#learn #software #testing #innovative #animated #videos #free #2022
Learn software testing free from innovative animated videos
   • Boundary Value Analysis | Black Box T...