I would like to know in which scenario I can use "Main sample" or "Sub Sample" or both for Text Response in Response Assertion.
I googled it but have not yet receive satisfactory answers yet.
Help appreciated.
Main sample only is the most common setting, this way the assertion will be applied only to the response to samplers not to sub samples. Sub samples in case of HTTP requests mainly refers to embedded resources. JMeter variable is useful to assert if a post processor contains the right value.
A sample is a portion of the population. A subsample is a portion of the sample. Copy link CC BY-SA 4.0.
Samplers in JMeter allows JMeter to send different types of requests to a server. Samplers are the actual requests, JMeter sends to the web server under test. Each sampler (except Test Action) generates one or more sample results. The sample results have various attributes (success/fail, elapsed time, data size etc.)
According to JMeter Help,
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
In most cases, only main sampler has all required response data but nowadays because of ajax, jquery framework single request can spawn multiple sub-requests internally and each has its response data.
Thus In most cases searching in main samplers response is enough
But if you know or you found out that request has multiple sub-requests and response can be anywhere then you can choose "main samples and sub samples" radio button so that you wont miss sub requests.
When you select 'Retrieve All Embedded Resources' the HTTP request you have it might generate sub samplers (for img, css, js files etc). You select the option in the Response Assertion accordingly based on the samplers where you expect your 'expected text' to be present.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With