• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

yxchun

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

Jmeter 加载Java代码并执行

BeanShell中引用外部类,有三种方法:

1)引用源文件,即.java文件。
2)引用字节码文件,即.class文件。
3)引用jar包,即.jar文件。

方法1 ,引用源文件

1)创建java文件

public class TestA{

    public static String test(String input) {
        String output = "Hello," + input;
        return output;
    }
}

2)在线程组里面添加BeanShell取样器

source("C:/Users/Administrator/Desktop/TestA.java");
String output = TestA.test("aaaaaa");
log.info(output);

Source加载的文件为绝对路径

 

 

 

 

 

 

 

 

 

参考:https://zhuanlan.zhihu.com/p/129297061

posted on 2023-01-11 14:07  yxchun  阅读(541)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3