4
votes

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.

1
can you show your test plan and zoom on the last sample and ifcontroller condition? thxUBIK LOAD PACK
Any of you using apache Jmeter 3.0 , you need to be careful about using the Debug Sampler in the thread. When we use the condition ${JMeterThread.last_sample_ok}==true , Jmeter looks into the last sampler result and checks if it was run successfully. If Debug sampler is between the assertion and the next if condition then the value of ${JMeterThread.last_sample_ok} will always be true even when the previous request assertion failed. source : sqa.stackexchange.com/questions/20732/…AmrithS

1 Answers

4
votes

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.