jmeter - Jmeter - matchNr 返回 null
问题描述
我在 JMeter 中使用 vars.put() 存储一个变量,当我尝试使用 _matchNr 时,它返回 null。在我调用_matchNr的同一文件中记录变量后,它显示了正确的输出(这应该意味着变量本身不为空)。那么,为什么 matchNr 给出空输出是有原因的?
log.info("this is transaction" + "${transactionAmountResp}");
log.info("this is transaction_match" +
vars.get("transactionAmountResp_matchNr"));
int number = Integer.parseInt("${transactionAmountResp_matchNr}");
我在 Beanshell Assertion 中使用它来检查 transactionAmountResp 是否与其他已设置的变量匹配。
解决方案
你不应该${}
在 Beanshell/JSR233 脚本中使用语法,使用vars.get
log.info("this is transaction" + vars.get("transactionAmountResp"));
int number = Integer.parseInt(vars.get("transactionAmountResp_matchNr"));
推荐阅读
- postgresql - 需要创建一个触发器,在插入后增加表中的值
- c# - 涉及硬件通信的单元测试值得吗?
- view - 是否可以从 SAS 视图表中获取源代码?
- regex - 如何对以下 CSV 进行批处理或 vbs 以删除某些字符?
- javascript - 如何使用滚动事件将新类添加到地图中的一个元素
- androidx - 不显示导航按钮(汉堡按钮)
- java - 如何实现帮助用户了解应用功能的对话框?
- c# - 如何使用 AzureAD 身份验证将 Asp.Net-Core 2.2 Razor Pages 应用程序部署到 Azure
- javascript - 纽约市伊斯坦布尔,生成带有测试用例名称的报告
- regex - 正则表达式从右到左获取子字符串