我正在尝试执行以下命令的JMeter测试。 https://www.blazemeter.com/blog/5-ways-launch-jmeter-test-without-using-jmeter-gui
public static void main(String[] argv) throws Exception {
// JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
// Initialize Properties, logging, locale, etc.
JMeterUtils.loadJMeterProperties("/work/apache-jmeter-5.0/bin/jmeter.properties");
JMeterUtils.setJMeterHome("/work/apache-jmeter-5.0");
//JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
JMeterUtils.initLocale();
// Initialize JMeter SaveService
SaveService.loadProperties();
// Load existing .jmx Test Plan
File in = new File("/work/apache-jmeter-5.0/extras/jmeter_test.jmx");
HashTree testPlanTree = SaveService.loadTree(in);
//in.close();
// Run JMeter Test
jmeter.configure(testPlanTree);
jmeter.run();
}
但是我总是会出错
由造成:com.thoughtworks.xstream.converters.ConversionException 你能帮我吗!
以下是详细信息错误:
Exception in thread "main" java.lang.IllegalArgumentException: Problem loading XML from:'/work/apache-jmeter-5.0/extras/jmeter_test.jmx'.
Cause:
CannotResolveClassException: org.apache.jmeter.protocol.http.control.CookieManager
cause-exception :
at org.apache.jmeter.save.ScriptWrapperConverter.createConversionException(ScriptWrapperConverter.java:102)
at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:96)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1486)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1466)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1337)
at org.apache.jmeter.save.SaveService.readTree(SaveService.java:452)
答案 0 :(得分:0)
可能的解决方案在这里描述: https://sqa.stackexchange.com/questions/24441/xml-loading-issue-with-jmx-generated-by-blazemeter-mobile-recorder
答案 1 :(得分:0)
您的JMeter安装已损坏或Java项目配置不正确。
确保此文件存在:
/work/apache-jmeter-5.0/lib/ext/ApacheJMeter_http.jar
如果是-将其添加到Java项目类路径中: