[英]JMeter - How to pass all the HTTP Request of my group to an if controller
I have a bunch of HTTP Requests inside my Threads group and I want all of them to be evaluated inside an IF Controller which has a specific condition. 我的线程组中有一堆HTTP请求,我希望所有这些请求都在具有特定条件的IF控制器中进行评估。
JRS233 Listener contains this script: JRS233侦听器包含以下脚本:
if (!prev.isSuccessful()) {
vars.put('samplerFailed', 'true')
}
if(prev.isSuccessful()) {
vars.put('samplerSuccess', 'true');
}
if CONTROLLER OK cointains this condition: 如果CONTROLLER OK符合以下条件:
${samplerFailed}
and if Controller KO has this condition: 如果KO管制员具有以下条件:
${samplerSuccess}
I want the two IF CONTROLLERS to be executed for all the samplers. 我希望对所有采样器执行两个IF CONTROLLER。
How can I achieve it? 我该如何实现?
thanks 谢谢
Add JSR223 Listener to your Test Plan (the same level as all the HTTP Request) and put the following code into "Script" area: 将JSR223侦听器添加到您的测试计划中(与所有HTTP请求处于同一级别),并将以下代码放入“脚本”区域:
if (!prev.isSuccessful()) { vars.put('samplerFailed', 'true') }
${samplerFailed}
将您的If Controller条件更改为${samplerFailed}
This way If Controller's children will be executed only if there is any failure in the samplers in scope of the JSR223 Listener . 这样,仅当采样器在JSR223侦听器范围内发生故障时,才会执行Controller的子级 。
You can loop through different URLs/ HTTP Requests and do same logic for each request. 您可以循环访问不同的URL / HTTP请求 ,并对每个请求执行相同的逻辑。
Put HTTP request and If Controllers under While Controller and add CSV Data Set Config that will read your URLs from a file. 将HTTP请求和If Controllers放在While Controller下,然后添加CSV数据集配置,该配置将从文件中读取URL。
While loop will stop until finish reading CSV file using ${url}
condition While循环将停止,直到使用${url}
条件完成读取CSV文件为止
your flow will remain the same, the only different it will be executed per line in CSV file. 您的流程将保持不变,唯一不同的是它将在CSV文件中每行执行一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.