Jmeter Beanshell预处理器未找到SampleResult

Jmeter Beanshell预处理器未找到SampleResult,jmeter,Jmeter,我是JMeter的新手,正在努力实现Beanshell预处理器。我的示例代码取自这个网站上的一篇文章- File querycsv = new File("xlocalTestData.csv"); if (!querycsv.exists()){ SampleResult.setSuccessful(false); SampleResult.setRespnseMessage("Failed to find CSV file"); SampleResult.setDa

我是JMeter的新手,正在努力实现Beanshell预处理器。我的示例代码取自这个网站上的一篇文章-

File querycsv = new File("xlocalTestData.csv");

if (!querycsv.exists()){
    SampleResult.setSuccessful(false);
    SampleResult.setRespnseMessage("Failed to find CSV file");
    SampleResult.setData("Unable to locate CSV file under path: " + querycsv.getPath(),"UTF-8");
    IsSuccess = false;
    SampleResult.setStopTestNow(true);
在互联网上翻找,我找到了这份进口声明-

import org.apache.jmeter.samplers.SampleResult;
但是,如果csv文件丢失,则在传递损坏的文件名以测试失败时,我会遇到此错误-

2014/03/03 13:11:11 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
2014/03/03 13:11:11 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2014/03/03 13:11:11 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*) 
2014/03/03 13:11:11 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Report Service Group 1 
2014/03/03 13:11:11 INFO  - jmeter.engine.StandardJMeterEngine: Starting 5 threads for group Report Service Group 1. 
2014/03/03 13:11:11 INFO  - jmeter.engine.StandardJMeterEngine: Thread will start next loop on error 
2014/03/03 13:11:11 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 5 ramp-up 5 perThread 1000.0 delayedStart=true 
2014/03/03 13:11:11 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
2014/03/03 13:11:11 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2014/03/03 13:11:11 INFO  - jmeter.threads.JMeterThread: Thread started: Report Service Group 1 1-1 
2014/03/03 13:11:11 INFO  - jmeter.services.FileServer: Stored: /home/brad/JMeter/ReportService/localTestData.csv Alias: /home/brad/JMeter/ReportService/localTestData.csv@1567545803 
2014/03/03 13:11:11 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:11 WARN  - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:11 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:11 WARN  - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:11 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:11 WARN  - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:11 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:11 WARN  - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:12 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:12 WARN  - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:12 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval   Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:12 WARN  - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult;  File querycsv = new File("xloca . . . '' : Cannot reach instance method: setSuccessful( boolean ) from static context: org.apache.jmeter.samplers.SampleResult 
2014/03/03 13:11:12 INFO  - jmeter.threads.JMeterThread: Thread started: Report Service Group 1 1-2 
不是Java程序员,我猜我没有设置include路径?有人能给我指点解决办法吗

我正在运行ApacheJMeter(2.11R1554548)的Centos 6桌面上运行此程序

谢谢你的帮助

谢谢

Brad

您需要使用的是,而不是Beanshell预处理器

SampleResult
是一个预定义变量,仅适用于Beanshell Sampler,前置处理器和后置处理器均无权访问该变量


有关更多详细信息,请参阅指南

谢谢DMitri,这很有教育意义:)我的JMeter版本中没有Beanshell采样器。或者我找错地方了。。。我有一个Beanshell断言。我尝试将代码添加到其中,现在得到了另一个错误-在类“org.apache.jmeter.protocol.http.sampler.httpsamplesult”中找不到方法setData(java.lang.String,java.lang.String)。我将尝试删除callNice教程Dmitri。你写的?我找到了一个Beanshell的听众,你提到的采样器是用新名字命名的吗?删除对setdata的调用似乎有效,日志显示两个线程报告“立即停止测试”,测试退出。Thaks:)Beanshell sampler在相当长一段时间内都是默认组件,它位于
Samplers
下,但您必须在线程组范围内。如果右键单击采样器,即HTTP请求或任何其他采样器,则无法添加子采样器,只能添加前置/后置处理器、断言、配置元素或侦听器。只要上升一级,你们就会看到增加一个采样器的可能性。谢谢你们。所以我找错地方了:)。然而,我发现同样的代码也适用于Beanshell断言。两者都终止了测试,我在日志中看到了这一点——“jmeter.threads.JMeterThread:Stop test Now detected by thread:Report Service Group 1 1-1”感谢您的帮助,我一直在努力解决这个问题。您有一个打字错误。setResponseMessage(应为setResponseMessage(