如何从 Jmeter 执行 java 类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3768590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to execute java class from Jmeter
提问by ant
Is there a way to execute java class from jmeter? I've packaged my class with maven assembly and put it in the lib folder of JMETER_HOME. Then I created BSF Listener inside my test case and wrote :
有没有办法从jmeter执行java类?我已经用 maven 程序集打包了我的类并将其放在 JMETER_HOME 的 lib 文件夹中。然后我在我的测试用例中创建了 BSF Listener 并写道:
import my.package.name.App;
my.package.name.App app = new my.package.name.App("argument1", "argument2");
Is there another way to execute java class or whatever maybe with java -jar call the jar directly , this class basically creates one big file from the smaller files, which locations are provided by jmeter so it needs to be included in the test because its the part of the flow.
是否有另一种方法来执行 java 类或任何可能使用 java -jar 直接调用 jar 的方法,此类基本上从较小的文件创建一个大文件,这些位置由 jmeter 提供,因此需要将其包含在测试中,因为它是流的一部分。
采纳答案by Adnan
Try BSF Samplerinstead of BSF Listener, in scripting language field select beanshell
and it will work like a charm.
尝试BSF Sampler而不是BSF Listener,在脚本语言字段选择中beanshell
,它会像魅力一样工作。
回答by Henry Aloni
The simplest way is to create your own sampler for jmeter. Here's a simple example to show you how: https://newspaint.wordpress.com/2012/11/28/creating-a-java-sampler-for-jmeter/
最简单的方法是为 jmeter 创建自己的采样器。这是一个简单的示例,向您展示如何操作:https: //newspaint.wordpress.com/2012/11/28/creating-a-java-sampler-for-jmeter/