请为我所遇到的以下情况提供好的设计和实现建议。
设计
Sampler 1 (prerequisite)
Sampler 2 (prerequisite)
Sampler 3 (actual test)
执行
Sampler 1 failed with error
Sampler 2 not executed
Sampler 3 not executed but marked as failed with Sampler 1 error or executed but result data replaced with error from Sampler 1
注意:最终结果报告中排除了必备的采样器(已经找到相应的解决方案)。
答案 0 :(得分:0)
您可以按照以下方式设计测试:
采样器1
JSR223 PostProcessor,其代码如下:
if (!prev.isSuccessful()) {
vars.putObject('sampler1Result', prev)
}
${JMeterThread.last_sample_ok}
采样器3
JSR223后处理器,带有以下代码:
if (vars.getObject('sampler1Result') != null) {
def sampler1Result = vars.getObject('sampler1Result')
prev.setSuccessful(sampler1Result.isSuccessful())
prev.setResponseCode(sampler1Result.getResponseCode())
prev.setResponseMessage(sampler1Result.getResponseMessage())
prev.setResponseData(sampler1Result.getResponseData())
}
位置:
vars
-是JMeterVariables类实例的简写prev
-是HTTPSampleResult类实例的简写