The response assertion control panel lets you add pattern strings to be compared against various fields of the 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 overriden. 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. Control Panel Parameters Attribute | Description | Required |
---|
Name | Descriptive name for this element that is shown in the tree. | No | Apply to: | This is for use with samplers that can generate sub-samples, e.g. HTTP Sampler with embedded resources, Mail Reader or samples generated by the Transaction Controller.- Main sample only - assertion only applies to the main sample
- Sub-samples only - assertion only applies to the sub-samples
- Main sample and sub-samples - assertion applies to both.
- JMeter Variable - assertion is to be applied to the contents of the named variable
| Yes | Response Field to Test | Instructs JMeter which field of the Response to test.- Text Response - the response text from the server, i.e. the body, excluding any HTTP headers.
- Document (text) - the extract text from various type of documents via Apache Tika (see View Results Tree Document view section).
- URL sampled
- Response Code - e.g. 200
- Response Message - e.g. OK
- Response Headers, including Set-Cookie headers (if any)
| Yes | Ignore status | Instructs JMeter to set the status to success initially. The overall success of the sample is determined by combining the result of the assertion with the existing Response status. When the Ignore Status checkbox is selected, the Response status is forced to successful before evaluating the Assertion. HTTP Responses with statuses in the 4xx and 5xx ranges are normally regarded as unsuccessful. The "Ignore status" checkbox can be used to set the status successful before performing further checks. Note that this will have the effect of clearing any previous assertion failures, so make sure that this is only set on the first assertion. | Yes | Pattern Matching Rules | Indicates how the text being tested is checked against the pattern.- Contains - true if the text contains the regular expression pattern
- Matches - true if the whole text matches the regular expression pattern
- Equals - true if the whole text equals the pattern string (case-sensitive)
- Substring - true if the text contains the pattern string (case-sensitive)
Equals and Substring patterns are plain strings, not regular expressions. NOT may also be selected to invert the result of the check. | Yes | Patterns to Test | A list of patterns to be tested. Each pattern is tested separately. If a pattern fails, then further patterns are not checked. There is no difference between setting up one Assertion with multiple patterns and setting up multiple Assertions with one pattern each (assuming the other options are the same). However, when the Ignore Status checkbox is selected, this has the effect of cancelling any previous assertion failures - so make sure that the Ignore Status checkbox is only used on the first Assertion. | Yes |
The pattern is a Perl5-style regular expression, but without the enclosing brackets. Assertion Examples Figure 14 - Test Plan |
Figure 15 - Assertion Control Panel with Pattern |
Figure 16 - Assertion Listener Results (Pass) |
Figure 17 - Assertion Listener Results (Fail) |
|