无法在JMeter中运行IntelliJ IDEA的参数化JUnit测试
在JMeter中启动IntelliJ IDEA参数化测试的问题
我需要找到在JMeter中启动IntelliJ IDEA里参数化测试的方法。此前已获取过相关启动测试的帮助,但仍无法运行测试,测试似乎对JMeter不可见。我已将JUnit 5及其所有依赖jar包、项目所有依赖添加至JMETER_HOME/lib目录,同时也将包含测试类的jar包放入该目录。
JSR223 Sampler中使用的代码
import org.junit.platform.launcher.Launcher import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder import org.junit.platform.launcher.core.LauncherFactory import org.junit.platform.launcher.listeners.SummaryGeneratingListener import org.junit.platform.launcher.listeners.TestExecutionSummary import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; import static org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod; import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.*; def listener = new SummaryGeneratingListener() def request = LauncherDiscoveryRequestBuilder.request() .selectors( selectClass(com.example.MyTest.class), selectMethod(com.example.MyTest.class, "myTest", String.class)).build() def launcher = LauncherFactory.create() launcher.discover(request) launcher.registerTestExecutionListeners(listener) launcher.execute(request) def summary = listener.getSummary() log.info('Total tests executed: ' + summary.getTestsFoundCount()) log.info('Total tests succeeded: ' + summary.getTestsSucceededCount()) log.info('Total tests failed: ' + summary.getTestsFailedCount())
运行日志
2023-08-14 12:05:13,051 INFO o.a.j.s.FileServer: Default base='...\apache-jmeter-5.6.2\bin' 2023-08-14 12:05:13,056 INFO o.a.j.g.a.Load: Loading file: ...\apache-jmeter-5.6.2\bin\MyTest\Test.jmx 2023-08-14 12:05:13,056 INFO o.a.j.s.FileServer: Set new base='...\apache-jmeter-5.6.2\bin\MyTest' 2023-08-14 12:05:13,266 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2 2023-08-14 12:05:13,281 INFO o.a.j.s.SaveService: Using SaveService properties version 5.0 2023-08-14 12:05:13,281 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8 2023-08-14 12:05:13,286 INFO o.a.j.s.SaveService: Loading file: ...\apache-jmeter-5.6.2\bin\MyTest\Test.jmx 2023-08-14 12:05:14,051 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times 2023-08-14 12:05:14,051 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to UTF-8 2023-08-14 12:05:14,051 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true 2023-08-14 12:05:14,051 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000 2023-08-14 12:05:14,537 INFO o.a.j.s.FileServer: Set new base='...\apache-jmeter-5.6.2\bin\MyTest' 2023-08-14 12:05:28,217 INFO o.a.j.e.StandardJMeterEngine: Running the test! 2023-08-14 12:05:28,222 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2023-08-14 12:05:28,222 INFO o.a.j.s.SampleEvent: List of sample_variables: [] 2023-08-14 12:05:28,222 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must contain the string: '.functions.' 2023-08-14 12:05:28,222 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must not contain the string: '.gui.' 2023-08-14 12:05:28,527 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*) 2023-08-14 12:05:28,527 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group 2023-08-14 12:05:28,527 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group. 2023-08-14 12:05:28,527 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error 2023-08-14 12:05:28,532 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false 2023-08-14 12:05:28,542 INFO o.a.j.t.ThreadGroup: Started thread group number 1 2023-08-14 12:05:28,542 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started 2023-08-14 12:05:28,547 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1 2023-08-14 12:05:30,038 INFO c.w.a.u.ConfigurationInfo: The target execution environment is: ... 2023-08-14 12:05:30,043 INFO c.w.a.u.ConfigurationInfo: The target execution site page is: ... 2023-08-14 12:05:30,048 INFO c.w.a.u.TestListener: Test result summary for MyTest {} 2023-08-14 12:05:30,083 INFO o.a.j.p.j.s.J.J.2 sampler: Total tests executed: 0 2023-08-14 12:05:30,083 INFO o.a.j.p.j.s.J.J.2 sampler: Total tests succeeded: 0 2023-08-14 12:05:30,083 INFO o.a.j.p.j.s.J.J.2 sampler: Total tests failed: 0 2023-08-14 12:05:30,093 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1 2023-08-14 12:05:30,093 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1 2023-08-14 12:05:30,093 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test 2023-08-14 12:05:30,093 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
内容的提问来源于stack exchange,提问作者Anastasiia Stelmakhova
相关产品推荐
相关产品推荐

