JMeter - 某些功能无法在功能助手

时间:2018-02-13 06:51:17

标签: jmeter jmeter-4.0

关于JMeter功能助手对话框,它是一个很棒的工具,但是当期望变量可用时,某些功能无法使用它来执行

__split函数具有强制变量名称抛出异常,例如在调用${__split(a,a,)}

函数__isVarDefined也会出现NullPointerException:

2018-02-12 08:03:20,603 ERROR o.a.j.e.ClientJMeterEngine: Error calling function ${__split(a,a,)}
java.lang.UnsupportedOperationException: null
    at org.apache.jmeter.threads.UnmodifiableJMeterVariables.put(UnmodifiableJMeterVariables.java:73) ~[ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.functions.SplitFunction.execute(SplitFunction.java:99) ~[ApacheJMeter_functions.jar:4.0 r1823414]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:137) ~[ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:112) ~[ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.functions.gui.FunctionHelper.actionPerformed(FunctionHelper.java:200) [ApacheJMeter_core.jar:4.0 r1823414]
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) [?:1.8.0_25]
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) [?:1.8.0_25]
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) [?:1.8.0_25]
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source) [?:1.8.0_25]
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.processMouseEvent(Unknown Source) [?:1.8.0_25]
    at javax.swing.JComponent.processMouseEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.processEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Container.processEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Container.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.dispatchEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Container.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Window.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.dispatchEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue.access$400(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_25]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) [?:1.8.0_25]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$4.run(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$4.run(Unknown Source) [?:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_25]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue.dispatchEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) [?:1.8.0_25]
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) [?:1.8.0_25]
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) [?:1.8.0_25]
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [?:1.8.0_25]
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) [?:1.8.0_25]
    at java.awt.EventDispatchThread.run(Unknown Source) [?:1.8.0_25] 

JMeter 4中的新函数__isVarDefined也会出现NullPointerException:

2018-02-11 10:32:38,093 ERROR o.a.j.e.ClientJMeterEngine: Error calling function ${__isVarDefined(a)}
java.lang.NullPointerException: null
    at org.apache.jmeter.functions.IsVarDefined.execute(IsVarDefined.java:53) ~[ApacheJMeter_functions.jar:4.0 r1823414]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:137) ~[ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:112) ~[ApacheJMeter_core.jar:4.0 r1823414]
    at org.apache.jmeter.functions.gui.FunctionHelper.actionPerformed(FunctionHelper.java:200) [ApacheJMeter_core.jar:4.0 r1823414]
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) [?:1.8.0_25]
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) [?:1.8.0_25]
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) [?:1.8.0_25]
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source) [?:1.8.0_25]
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.processMouseEvent(Unknown Source) [?:1.8.0_25]
    at javax.swing.JComponent.processMouseEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.processEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Container.processEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Container.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.dispatchEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.Container.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Window.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.Component.dispatchEvent(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue.access$400(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$3.run(Unknown Source) [?:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_25]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) [?:1.8.0_25]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$4.run(Unknown Source) [?:1.8.0_25]
    at java.awt.EventQueue$4.run(Unknown Source) [?:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_25]

JMeter是否应该在函数助手中初始化变量,或者它是否无关紧要,因此需要在没有变量上下文的情况下添加一个不可用的警告?

1 个答案:

答案 0 :(得分:1)

在函数助手对话框中通常无法测试的函数需要一些上下文:

  • 属性设置
  • 设置变量 ...

这是在以下增强中确定的限制:

如果您有任何想法,请随意提供补丁,例如:

  • 可以创建一个空的JMeterVariable
  • 用户可以输入一些Groovy代码以填写此对象或其他属性的文本区域

这样任何功能都可以测试。