Shivyesh Agnihotri
Shivyesh Agnihotri

Reputation: 11

Jmeter action based on assertion result

I am using a HTTP request with duration assertion of 1 second. I want an alerting system slack/mail whenever my assertion fails. Is it possible to do so using Jmeter ? if yes how ?

Upvotes: 1

Views: 217

Answers (2)

Dmitri T
Dmitri T

Reputation: 168157

  1. Add If Controller after the request which may be not successful
  2. Use the following __jexl3() function as the condition:

    ${__jexl3(${JMeterThread.last_sample_ok} == false,)}
    

    enter image description here

    JMeterThread.last_sample_ok is a pre-defined JMeter Variable which holds the result of previous Sampler execution so If Controllers child/children will be only executed if the previous request is not successful.

  3. Put the logic which sends email or slack notification as a child of the If Controller
  4. That's it, the notification will be sent only if the sampler is not successful

    enter image description here

Upvotes: 1

Parth Mehta
Parth Mehta

Reputation: 1927

  1. You save the assertion result to a var. see: JMeter - save assertion results as a variable
  2. Use if controller to decide weather to send slack / mail.

Upvotes: 0

Related Questions