user2173353
user2173353

Reputation: 4660

JMeter - how to check if there are any failing assertions with BeanShell

I want to make my continuous integration system understand when a JMeter test has failed.

I am thinking of using the stdout logs for that.

Is there a way to check inside a BeanShell PostProcessor if there are failing assertions?

Then I can log a GUID or something like that to signify that the test has failed. Also, any idea how to log to stdout and not only inside the log file? JMeter logs some info to stdout but I am not sure if a log.error("code") will go there.

If there is any easier way, feel free to share.

Upvotes: 0

Views: 379

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

  1. According to JMeter Test Elements execution order Post-Processors are being called before Assertions so you need Listener which is the last element
  2. Starting from JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting

Assuming all above you need to add JSR223 Listener with the following code:

prev.getAssertionResults().each { assertionResult ->
  if (assertionResult.isFailure()) {
      println('Assertion failed')
  }
}

enter image description here

Upvotes: 1

Related Questions