How to execute java class from Jmeter

ε祈祈猫儿з 提交于 2019-12-20 02:47:17

问题


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 :

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.


回答1:


Try BSF Sampler instead of BSF Listener, in scripting language field select beanshell and it will work like a charm.




回答2:


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/



来源:https://stackoverflow.com/questions/3768590/how-to-execute-java-class-from-jmeter

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