Load a file content to be used in a test with JMeter and a AbstractJavaSamplerClient

巧了我就是萌 提交于 2021-01-29 07:03:54

问题


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

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.

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

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


回答1:


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

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

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.



来源:https://stackoverflow.com/questions/25767654/load-a-file-content-to-be-used-in-a-test-with-jmeter-and-a-abstractjavasamplercl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!