I have a HTTP request sampler with a response and a duration assertion. Now when the response assertion fails the next HTTP request sampler is not allowed to run. Only when the duration assertion fails the next HTTP request sampler is allowed to run.
I started doing this with an IF Controller
and checking ${JMeterThread.last_sample_ok}
but that was, when I only had the response assertion in place. When adding the duration assertion and the new requirement this no longer applied.
I have tried BeanShell Post Processors to add certain variables when the duration assertion fails. But the following code is always giving me back and empty array event when the duration assertion fails.
BeanShell Post Processor code:
import org.apache.jmeter.assertions.AssertionResult;
AssertionResult[] results = prev.getAssertionResults();
if (results.length == 0) {
vars.put("assertions_have_zero_length", "true");
}
//debug post processor shows the above variable.
I have also tried to use a BeanShell listener and this does give me back two assertions but when creating (putting) certain variables they aren't shown in the debug post processor.
BeanShell Listener code:
import org.apache.jmeter.assertions.AssertionResult;
AssertionResult[] results = sampleResult.getAssertionResults();
System.out.println("Current counter value = " + results.length);
if (results.length == 0) {
vars.put("assertions_have_zero_length", "true");
} else {
vars.put("assertions_have_zero_length", "false");
}
//no assertion_have_zero_length variable shown in debug post processor.
Am I doing something wrong and is it even possible what I want?
Thanks in advance.