Beanshell PreProcessor没有找到SampleResult

时间:2014-03-03 13:23:02

标签: jmeter

我是JMeter的新手,正在努力实现Beanshell PreProcessor。我从这个网站上的帖子中获取了这个示例代码 -

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程序员我猜我没有设置包含路径?有人能够指出我的决议吗?

我在运行Apache JMeter的Centos 6桌面上运行它(2.11 r1554548)

任何帮助表示赞赏

由于

布拉德

1 个答案:

答案 0 :(得分:1)

您需要使用Beanshell Sampler,而不是Beanshell Pre Processor。

SampleResult是一个预定义的变量,仅适用于Beanshell Sampler,前处理器和后处理器都无法访问它。

有关详细信息,请参阅How to use BeanShell指南。