首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Beanshell PreProcessor找不到SampleResult

Beanshell PreProcessor找不到SampleResult
EN

Stack Overflow用户
提问于 2014-03-03 21:23:02
回答 1查看 6.5K关注 0票数 0

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

代码语言:javascript
运行
复制
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);

我在网上翻了翻,发现了这条重要的声明-

代码语言:javascript
运行
复制
import org.apache.jmeter.samplers.SampleResult;

但是,如果csv文件丢失,则传递损坏的文件名以测试是否失败时会出现此错误-

代码语言:javascript
运行
复制
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路径?有没有人能给我指点解决方案?

我在一台运行Apache JMeter (2.11 r1554548)的CentOS6台式机上运行它。

感谢您的任何帮助

谢谢

布拉德

EN

回答 1

Stack Overflow用户

发布于 2014-03-03 21:50:01

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

SampleResult是一个预定义的变量,它只对Beanshell采样器可用,无论是预处理还是后处理都无法访问它。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22147958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档