javascript - JMeter duration assertion Override Response Code -
i have jmeter test plan executes 1 http request multiple times per second. parameter have timeout every request test executes. have added "duration assertion" sampler/listener/ idk^^
now running test , getting response code 200 because request ok duration assertion exceeded. causes in results tree there succeeded , failed requests of them have status code 200. problem in "response codes per second" listener shows requests ok , have response code 200. not ok because of duration assertion!
my problem: override status code of requests failed due duration assertion. want them displayed different response code (but if exceed duration assertion) in "response codes per second" listener because cant distinguish them. or there way can make them fail when exceed timeout?
i sorry english , hope can understand problem. lot!
i'm not aware of test elements allow changing response code, can via scripting follows:
add beanshell assertion child of request want fail. beanshell assertion should go after duration assertion
add following code "script" area:
import org.apache.jmeter.assertions.assertionresult; assertionresult[] results = prev.getassertionresults(); (assertionresult result : results) { if (result.isfailure()) { if (result.getfailuremessage().contains("the operation lasted long")) { sampleresult.setresponsecode("1000"); } } }
see how use jmeter assertions in 3 easy steps more information on conditionally passing/failing jmeter samplers via assertions.
Comments
Post a Comment