JMeter上的HTTP请求测试失败 [英] HTTP request on JMeter test failure
问题描述
在我的JMeter测试中,如果有任何错误,我想触发HTTP请求以在系统上发布消息,以进一步关注.我在这里可以做什么?邮件可视化工具可以很好地通过电子邮件报告错误.我想做同样的事情,但是要通过HTTP请求.我正在使用jmeter 3.2.
In my JMeter test, if there is any error, I want to trigger HTTP request to post a message on my system for further attention. What can I do here? Mail visualiser works fine to report errors over email. I want to do the same but over HTTP request. I am using jmeter 3.2.
推荐答案
您可以执行以下操作:
-
在HTTP请求采样器之后添加 If Controller 将以下代码放入条件"区域:
Add If Controller after the HTTP Request sampler and put the following code into "Condition" area:
`!${JMeterThread.last_sample_ok}`
JMeterThread.last_sample_ok
是预定义的JMeter变量,用于保存结果如果先前的采样器执行成功,则如果先前的采样器成功执行,则为true
,否则为false
.由于使用了If Controller,因此仅在HTTP Request采样器失败的情况下才执行SMTP请求采样器,这似乎是您要寻找的东西.
JMeterThread.last_sample_ok
is a pre-defined JMeter Variable holding the result of previous sampler execution, it is true
if previous sampler is successful and false
otherwise. Due to the If Controller the SMTP Request sampler will only be executed in case of HTTP Request sampler failure which seems to be something you're looking for.
这篇关于JMeter上的HTTP请求测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!