我正在加载测试API,我正在从CSV中获取测试数据
以下是我的csv的样子
我的if控制器是这样的
但是,当我运行线程组时,我收到以下错误:
2017/08/04 09:52:14 ERROR - jmeter.control.IfController: Check Country: error while processing [USA==USA]
org.mozilla.javascript.EcmaError: ReferenceError: "USA" is not defined. (<cmd>#1)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3951)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3929)
at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:4019)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1851)
at org.mozilla.javascript.gen._cmd__4._c_script_0(<cmd>:1)
at org.mozilla.javascript.gen._cmd__4.call(<cmd>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3282)
at org.mozilla.javascript.gen._cmd__4.call(<cmd>)
at org.mozilla.javascript.gen._cmd__4.exec(<cmd>)
at org.mozilla.javascript.Context.evaluateString(Context.java:1219)
at org.apache.jmeter.control.IfController$RhinoJsEngine.evaluate(IfController.java:105)
at org.apache.jmeter.control.IfController.evaluateCondition(IfController.java:187)
at org.apache.jmeter.control.IfController.next(IfController.java:240)
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:222)
at org.apache.jmeter.control.GenericController.next(GenericController.java:176)
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:222)
at org.apache.jmeter.control.GenericController.next(GenericController.java:176)
at org.apache.jmeter.control.LoopController.next(LoopController.java:123)
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:222)
at org.apache.jmeter.control.GenericController.next(GenericController.java:176)
at org.apache.jmeter.control.LoopController.next(LoopController.java:123)
at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:87)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:247)
at java.lang.Thread.run(Thread.java:745)
我是jmeter的新手,所以我猜这里错过了一些东西。任何帮助将不胜感激。
答案 0 :(得分:0)
因此,在做了一些研究之后,我发现String表达式需要双引号才能使它们起作用。
因此,以下条件有效
"${CTRY}"=="USA"
答案 1 :(得分:0)
建议在JMeter中使用Groovy language for any form of scripting,因此我建议通过__groovy() function设置If Controller条件(自JMeter 3.0起可用),相关的Groovy表达式如下: / p>
${__groovy(vars.get('CTRY') == 'USA',)}