Assertions & Execution Order

Assertions & Execution Order

Let us discuss the Assertions & Execution Order.

Assertions- Assertions allow you to assert facts about responses received from the server being tested. Using an assertion, you can essentially “test” that your application is returning the results you expect it to.

For instance, you can assert that the response to a query will contain some particular text. The text you specify can be a Perl-style regular expression, and you can indicate that the response is to contain the text, or that it should match the whole response.

You can add an assertion to any Sampler. For example, you can add an assertion to a HTTP Request that checks for the text, “</HTML>”. JMeter will then check that the text is present in the HTTP response. If JMeter cannot find the text, then it will mark this as a failed request.

Note that assertions apply to all samplers which are in its scope . To restrict the assertion to a single sampler, add the assertion as a child of the sampler. To view the assertion results, add an Assertion Listener to the Thread Group. Failed Assertions will also show up in the Tree View and Table Listeners, and will count towards the error %age for example in the Aggregate and Summary reports

Execution order
  • Configuration elements
  • Pre-Processors
  • Timers
  • Sampler
  • Post-Processors (unless SampleResult is null)
  • Assertions (unless SampleResult is null)
  • Listeners (unless SampleResult is null)

Please note that Timers, Assertions, Pre- and Post-Processors are only processed if there is a sampler to which they apply. Logic Controllers and Samplers are processed in the order in which they appear in the tree. Other test elements are processed according to the scope in which they are found, and the type of test element. [Within a type, elements are processed in the order in which they appear in the tree].

For example, in the following test plan:

Controller

  • Post-Processor 1
  • Sampler 1
  • Sampler 2
  • Timer 1
  • Assertion 1
  • Pre-Processor 1
  • Timer 2
  • Post-Processor 2

The order of execution would be:

  • Pre-Processor 1
  • Timer 1
  • Timer 2
  • Sampler 1
  • Post-Processor 1
  • Post-Processor 2
  • Assertion 1
  • Pre-Processor 1
  • Timer 1
  • Timer 2
  • Sampler 2
  • Post-Processor 1
  • Post-Processor 2
  • Assertion 1

Test Your Software Testing Skills By Taking Our JMeter Practice Tests On This Link

Become Vskills Certified JMeter Tester. Gain some knowledge on the module “Assertions & Execution Order”. Try the free practice test!

Apply For JMeter Certification

Go back to Tutorial

Listeners & Timers
Properties and Variables

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?