jmeter - Beanshell 函数在 if/else 评估之前被调用
问题描述
我创建了 2 个 BeanShell 函数 myFoo1 和 myFoo2。
第一个函数应在特定条件下执行,第二个函数应在不同条件下执行
问题是在我的 JSR223Post Processor 或 BeanPost Processor
String code = ctx.getPreviousResult().getResponseCode();
if (code.contains("200") && (vars.get("abc1") != "Howdee")) {
${__BeanShell(myFoo1("print this"))}
}
else {
${__BeanShell(myFoo2("print this"))}
}
问题是 beanShell 函数 myFoo1 和 myFoo2 在 if/else 评估之前被调用。
换句话说,myFoo1 和 myFoo2 它们都被一个接一个地调用,并且 if/else 从来没有任何效果,所以看起来 Bean 函数调用是在任何评估之前执行的。我该如何解决?
解决方案
${__BeanShell(
从脚本中删除并直接调用它myFoo2("print this)
:
String code = ctx.getPreviousResult().getResponseCode();
if (code.contains("200") && (vars.get("abc1") != "Howdee")) {
myFoo1("print this);
}
else {
myFoo2("print this);
}
推荐阅读
- python - 在odoo-12中显示组中的数字总和
- java - 删除 launch4j 中的 java 选项
- kotlin - Kotlin jvm html DOCTYPE
- arrays - 如何在 Kotlin 中创建可以保存任何数据类型(包括空值)的空数组
- vue.js - DaisyUI:当语言切换到 RTL 之一时,如何将方向切换到 RTL?
- reactjs - 如何使用 history.push 传递多个参数?
- java - 将模块添加到项目时出错:非法字符:> 在索引 23
- python - 将一个张量乘以一个标量得到一个由 Nans 组成的张量
- java - IntelliJ 依赖项 - 规范和实现之间的差异
- c++ - 请求输入时强制用户输入特定模式