Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jmeter 如何获取由三个请求组成的事务控制器的名称和其他属性?_Jmeter_Beanshell - Fatal编程技术网

Jmeter 如何获取由三个请求组成的事务控制器的名称和其他属性?

Jmeter 如何获取由三个请求组成的事务控制器的名称和其他属性?,jmeter,beanshell,Jmeter,Beanshell,我的脚本结构如下所示: 事务控制器搜索提供事务 http请求提供 http请求提供详细信息 比恩希尔后处理器 哪个BeanShell命令允许我获取整个事务的名称、响应代码、响应时间、测试结果和测试时间 我应该在哪里安装BeanShell后处理器? 我应该使用哪种代码,但在我看来 字符串名称=sampler.getName() 无法正常工作。在我看来,您应该使用BeanShell Listener而不是BeanShell后处理器。侦听器可以位于当前Beanshell后处理器所在的位置。该对象可

我的脚本结构如下所示:

事务控制器搜索提供事务

  • http请求提供

  • http请求提供详细信息

比恩希尔后处理器

哪个BeanShell命令允许我获取整个事务的名称、响应代码、响应时间、测试结果和测试时间

我应该在哪里安装BeanShell后处理器? 我应该使用哪种代码,但在我看来

字符串名称=sampler.getName()


无法正常工作。

在我看来,您应该使用BeanShell Listener而不是BeanShell后处理器。侦听器可以位于当前Beanshell后处理器所在的位置。该对象可以访问
sampleResult
,其中将包含响应代码/响应时间等,例如:

sampleResult.getSampleLabel(); // the name, e.g. 'SEARCHING OFFERS Transaction'
SampleResult函数的完整列表如下所示
如果您只想在此侦听器中处理事务,则可以对其进行筛选(例如按名称)。

我认为您应该使用BeanShell listener而不是BeanShell后处理器。侦听器可以位于当前Beanshell后处理器所在的位置。该对象可以访问
sampleResult
,其中将包含响应代码/响应时间等,例如:

sampleResult.getSampleLabel(); // the name, e.g. 'SEARCHING OFFERS Transaction'
SampleResult函数的完整列表如下所示
如果您只想在此侦听器中处理事务,则可以对其进行筛选(例如按名称)。

Kiril,谢谢,我使用了您给我的代码和:String test=samplesult.getSampleLabel();日志信息(测试);对我来说效果很好,字符串test2=sampleResult.getResponseCode();log.info(test2);工作正常,一般所有方法都是字符串类型。不幸的是,我不知道如何使用方法getTime()-它是long类型,或者getSampleCount()-int类型。你能给我举几个例子如何使用方法吗?这些方法不是String类型的?我不确定我是否理解你的问题。你是说类似于
log.info(“+sampleResult.getTime())
long totalTime=sampleResult.getTime();日志信息(“+totalTime”)或者您可以像这样附加它们:
log.info(String.format(“%s,%s,%d,%d”,sampleResult.getSampleLabel(),sampleResult.getResponseCode(),sampleResult.getTime(),sampleResult.getSampleCount())是的,这正是我要查找的,但是当我尝试启动此代码log.info(String.format(“%s,%s,%d,%d”,sampleResult.getSampleLabel(),sampleResult.getResponseCode(),sampleResult.getTime(),sampleResult.getSampleCount())时;出现以下错误:2016/01/28 13:55:15错误-jmeter.util.BeanShellInterpreter:调用bsh方法时出错:评估源文件:内联评估:``log.info(String.format(“%s,%s,%d,%d”,sampleResult.getSampleLabel(),Sampler…'':方法调用时出错:静态方法格式(java.lang.String,java.lang.String,java.lang.String,long,int)在类“java.lang.String”中找不到。哦,对不起,我忘了它使用了一种旧式格式:
log.info(String.format(“%s,%s,%d,%d”,新对象[]{samplesult.getSampleLabel(),samplesult.getResponseCode(),samplesult.getTime(),samplesult.getSampleCount())
Kiril,谢谢,我使用了你给我的代码和:String test=samplesult.getSampleLabel();log.info(test);对我来说很好,String test2=samplesult.getResponseCode();log.info(test2);很好,通常所有方法都是字符串类型。不幸的是,我不知道如何使用方法getTime()-它是long类型,或者getSampleCount()-int类型。你能给我一些例子如何使用方法吗,这些方法不是String类型的吗?我不确定我是否理解你的问题。你的意思是像
log.info(“+sampleResult.getTime());
或者
long totalTime=sampleResult.getTime();log.info(“+totalTime”)
或者你可以像这样附加它们:
log.info(String.format(“%s,%s,%d,%d”,samplesult.getSampleLabel(),samplesult.getResponseCode(),samplesult.getTime(),samplesult.getSampleCount());
是的,这正是我想要的,但当我试图启动这个代码log.info(String.format(“%s,%s,%d,%d”),sampleResult.getSampleLabel(),sampleResult.getResponseCode(),sampleResult.getTime(),sampleResult.getSampleCount());出现以下错误:2016/01/28 13:55:15错误-jmeter.util.BeanShellInterpreter:调用bsh方法时出错:eval源文件:内联计算:``log.info(String.format(“%s,%s,%d,%d”,sampleResult.getSampleLabel(),Sampler…'':方法调用中的错误:在类'java.lang.String'中找不到静态方法格式(java.lang.String,java.lang.String,long,int),噢,对不起,我忘了它使用的是旧式格式:
log.info(String.format(“%s,%s,%d,%d”,新对象[]{sampleResult.getSampleLabel(),sampleResult.getResponseCode(),sampleResult.getTime(),sampleResult.getSampleCount());