Why "JMeterThread.last_sample_ok" is set to true on assertion failure

Michael S Daniel picture Michael S Daniel · Sep 2, 2014 · Viewed 9.8k times · Source

The jmeter document says

http://jmeter.apache.org/usermanual/component_reference.html#assertions

The variable JMeterThread.last_sample_ok is updated to "true" or "false" after all assertions for a sampler have been run.

I have a http sampler in my test plan which performs a login with couple of redirects.

Interestingly I find that JMeterThread.last_sample_ok is set true even after my assertion fails. I am using response assertion to assert a string after login. The variable is set true even when assertion fails. This causes the next "if controller" to proceed for the wrong responses as well. Am I missing some thing.

Thanks in Advance for your help.

Answer

Dmitri T picture Dmitri T · Sep 2, 2014

For my Apache JMeter 2.11 everything works as expected.

I'm using ${JMeterThread.last_sample_ok}==false condition in If Controller

Looking into Debug Sampler and View Results Tree Listener combination I can that "JMeterThread.last_sample_ok" variable value is "false" for the sampler, failed by an assertion.

Debug Sampler

So double check your clause in If Controller and perhaps perform a dry run with Debug Sampler and View Results Tree listener enabled. Check out How to debug your Apache JMeter script for details on JMeter script debugging techiques.