1

In BeanShell Assertion, I want to check whether current HTTP Sampler failed, if it failed, then collect the failure information.
SampleResult.isSuccessful() is used to check the whole Sampler status first.
If it doesn't return true, then call SampleResult.getFirstAssertionFailureMessage().

However, error message points HTTPSampleResult doesn't have this method.

ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``//PostProcessors are executed before any assertions import org.apache.jmeter.sam . . . '' : Typed variable declaration : Error in method invocation: Method getFirstAssertionFailureMessage() not found in class'org.apache.jmeter.protocol.http.sampler.HTTPSampleResult'

HTTPSamperResult api:http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.html
SamperResult api: https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html

In my script, method isSuccessful(), getSampleLabel(true), getSamplerData(), getResponseDataAsString() work fine, but not getFirstAssertionFailureMessage().

It really confuses me, does it mean HTTPSampleResult can only invoke part of the methods from SampleResult?
If yes, how can we identify the method list?

Warmer
  • 107
  • 1
  • 7

1 Answers1

1

It should work fine given you use JMeter version for which this JavaDoc is actual. If you're looking into the website - you should be running the latest version available at JMeter Downloads page.

For instance it works fine in JMeter 5.0

enter image description here

Also be aware that according to JMeter Best Practices you should be using JSR223 test elements and Groovy language for scripting so consider migrating to JSR223 Assertion.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks for suggestion. My JMeter version is 4.0. So the method is supported in version 5.0 only, right? If yes, may I know where to check the api for 4.0? – Warmer Jan 10 '19 at 07:11