加载要在JMeter和AbstractJavaSamplerClient测试中使用的文件内容 [英] Load a file content to be used in a test with JMeter and a AbstractJavaSamplerClient

查看:73
本文介绍了加载要在JMeter和AbstractJavaSamplerClient测试中使用的文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在这里我缺少有关如何使用JMeter的东西.

So there is something I'm missing here about how to use JMeter.

我在用户指南中读到我可以使用Java采样器运行测试.可以,因为我需要读取其中包含一些内容的文件,然后将其发送到存储引擎.

I was reading in the user guide that I can use a Java Sampler to run my test. It's ok because I need to read a file with some content in it and then send it to the storage engine.

因此,我开始使用AbstractJavaSamplerClient类编写一些单元测试来实现我的JavaSample版本.

So I was starting writing some unit tests to implement my version of a JavaSample using the class AbstractJavaSamplerClient.

我指望只在安装程序中加载一次文件,但这使我感到困惑,我无法使用采样器上下文将其传递给runTest方法.

I was counting to load the file in the setup just once, but it puzzles me the fact that I can;t pass it to the runTest method using the sampler context.

您如何做这样的事情?我的意思是,很明显,如果每次测试没有意义时,如果我浪费时间加载文件,

How do you do something like this? I mean, obviously if I lose time loading a file each time the test has no meaning

推荐答案

使用 __ FileToString()函数是否在需要的地方?

Wouldn't it be easier to use __FileToString() function wherever it's required?

如果您希望一次读取文件仅控制器一次可以用来将文件读入JMeter变量

If you want the file to be read just one time Once Only Controller can be used to read the file into a JMeter Variable

如果您要按照vlns的说明在多个线程组中重用该变量,则应将其转换为JMeter属性,因为Variables范围仅限于当前线程组.请参见如何在不同的线程组中使用变量.实施细节指南.

If you're going to re-use the variable in multiple thread groups as vlns says it should be converted to JMeter Property as Variables scope is limited to current thread group only. See How to Use Variables in Different Thread Groups.guide for implementation details.

这篇关于加载要在JMeter和AbstractJavaSamplerClient测试中使用的文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆