jmeter无法识别用户导入的Junit jar包的解决方法

本文介绍了一个关于在JMeter中使用Junit进行测试时遇到的问题及解决方案。作者最初将Junit的测试代码打包成jar文件并放置在JMeter的libjunit目录下,但无法在JMeter中识别。通过排查,发现未勾选Includetests选项,勾选后问题得以解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在IntelliJ IDEA写了些Junit的测试代码,导出jar包后,放到%JMETER_HOME%\lib\junit路径下,重启Jmeter。

在Junit请求页面愣是找不到我导入的jar包……

百度了一下,没有找到问题及解决办法。

看了下日志,并没有报错。

然后我再检查下jar包,发现我忘了勾选Include tests……(啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊!!!!马大哈,真可怕!!!!!!!!!!!!!!!!)

勾选后重新导出jar包,复制到%JMETER_HOME%\lib\junit路径下,重启Jmeter。

搞定!

2025-07-01 15:17:22,311 INFO o.j.r.JARSourceHTTP: Found cached repo 2025-07-01 15:17:22,536 INFO o.j.r.PluginManager: Plugins Status: [jpgc-plugins-manager=1.11, jmeter-core=5.6.3, jmeter-ftp=5.6.3, jmeter-http=5.6.3, jmeter-jdbc=5.6.3, jmeter-jms=5.6.3, jmeter-junit=5.6.3, jmeter-java=5.6.3, jmeter-ldap=5.6.3, jmeter-mail=5.6.3, jmeter-mongodb=5.6.3, jmeter-native=5.6.3, jmeter-tcp=5.6.3, jmeter-components=5.6.3] 2025-07-01 15:17:32,191 INFO o.a.j.s.FileServer: Default base='D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\bin' 2025-07-01 15:17:32,193 INFO o.a.j.g.a.Load: Loading file: D:\日常软件\H.Jmeter\查看结果树.jmx 2025-07-01 15:17:32,193 INFO o.a.j.s.FileServer: Set new base='D:\日常软件\H.Jmeter' 2025-07-01 15:17:32,240 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2 2025-07-01 15:17:32,240 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8 2025-07-01 15:17:32,240 INFO o.a.j.s.SaveService: Using SaveService properties version 5.0 2025-07-01 15:17:32,256 INFO o.a.j.s.SaveService: Loading file: D:\日常软件\H.Jmeter\查看结果树.jmx 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser 2025-07-01 15:17:32,319 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to UTF-8 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true 2025-07-01 15:17:32,557 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000 2025-07-01 15:17:32,636 INFO o.a.j.r.ClassFinder: Will scan jar D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\lib\ext\jmeter-plugins-manager-1.11.jar with filter ExtendsClassFilter [parents=[interface org.apache.jmeter.visualizers.ResultRenderer], inner=false, contains=null, notContains=null]. Consider exposing JMeter plugins via META-INF/services, and add JMeter-Skip-Class-Scanning=true manifest attribute so JMeter can skip classfile scanning 2025-07-01 15:17:32,636 INFO o.a.j.r.ClassFinder: Will scan jar D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\lib\ext\jmeter-plugins-manager-1.11.jar with filter ExtendsClassFilter [parents=[interface org.apache.jmeter.visualizers.RequestView], inner=false, contains=null, notContains=null]. Consider exposing JMeter plugins via META-INF/services, and add JMeter-Skip-Class-Scanning=true manifest attribute so JMeter can skip classfile scanning 2025-07-01 15:17:32,668 INFO o.a.j.s.FileServer: Set new base='D:\日常软件\H.Jmeter' 2025-07-01 15:17:37,105 INFO o.a.j.e.StandardJMeterEngine: Running the test! 2025-07-01 15:17:37,105 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2025-07-01 15:17:37,105 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2025-07-01 15:17:37,105 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must contain the string: '.functions.' 2025-07-01 15:17:37,105 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must not contain the string: '.gui.' 2025-07-01 15:17:37,254 INFO o.a.j.r.ClassFinder: Will scan jar D:\日常软件\H.Jmeter\apache-jmeter-5.6.3\lib\ext\jmeter-plugins-manager-1.11.jar with filter ExtendsClassFilter [parents=[interface org.apache.jmeter.functions.Function], inner=false, contains=null, notContains=null]. Consider exposing JMeter plugins via META-INF/services, and add JMeter-Skip-Class-Scanning=true manifest attribute so JMeter can skip classfile scanning 2025-07-01 15:17:37,254 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*) 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Starting setUp thread groups 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Starting setUp ThreadGroup: 1 : tbd 线程组 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group tbd 线程组. 2025-07-01 15:17:37,254 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error 2025-07-01 15:17:37,254 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false 2025-07-01 15:17:37,270 INFO o.a.j.t.ThreadGroup: Started thread group number 1 2025-07-01 15:17:37,270 INFO o.a.j.e.StandardJMeterEngine: Waiting for all setup thread groups to exit 2025-07-01 15:17:37,270 INFO o.a.j.t.JMeterThread: Thread started: tbd 线程组 1-1 2025-07-01 15:17:37,270 INFO o.a.j.p.h.s.HTTPHCAbstractImpl: Local host = jizhi 2025-07-01 15:17:37,285 INFO o.a.j.p.h.s.HTTPHC4Impl: HTTP request retry count = 0 2025-07-01 15:17:37,424 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``// JSR223 Sampler 中使用 import org.apache.http.client.methods.HttpPost; import org . . . '' : Typed variable declaration : Object constructor 2025-07-01 15:17:37,424 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``// JSR223 Sampler 中使用 import org.apache.http.client.methods.HttpPost; import org . . . '' : Typed variable declaration : Object constructor 2025-07-01 15:17:37,460 INFO o.a.j.t.JMeterThread: Thread is done: tbd 线程组 1-1 2025-07-01 15:17:37,460 INFO o.a.j.t.JMeterThread: Thread finished: tbd 线程组 1-1 2025-07-01 15:17:37,475 INFO o.a.j.e.StandardJMeterEngine: All Setup Threads have ended 2025-07-01 15:17:37,539 INFO o.a.j.e.StandardJMeterEngine: No enabled thread groups found 2025-07-01 15:17:37,539 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test 2025-07-01 15:17:37,539 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
最新发布
07-02
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值