从用户那里获取输入后,我需要在运行时将线程组,加速时间和循环计数传递给JMeter脚本。
为此,我创建了一个如下所示的bat文件:
@echo off
title Accepting User Inputs And Passing It To JMeter Scripts !!
echo Welcome To The World Of Performance Testing !!
set /p thread=Enter the count for thread groups:
set /p rampup=Enter the ramp up peroid:
set /p loopcount=Enter the loopcount:
set /p cd = "E:\apache-jmeter-3.2\bin"
%cd%\jmeter -n -t E:\apache-jmeter-3.2\bin\scripts\SampleTestPlan.jmx -l
E:\apache-jmeter-3.2\bin\results\result1.csv -JThread=%thread% -
JRampUp=%rampup% -JLoopCount=%loopcount%
pause
但是我得到的输出如下,它接受输入,但是我无法通过重定向到位置来启动命令以在非GUI模式下运行Jmeter- E:\ apache-jmeter-3.2 \ bin 使用.bat文件。
答案 0 :(得分:1)
尝试在另一个(即“新鲜”)terminal window中运行脚本,您的脚本看起来或多或少都不错,这可能是因为您在其他位置定义了%cd%
变量并且它覆盖了设置从批处理脚本。
还请注意,according to JMeter Best Practices you should always be using the latest version of JMeter请考虑尽快升级到JMeter 5.0(或JMeter Downloads页上可用的最新版本)
答案 1 :(得分:1)
转到脚本中的jmeter目录:
E:
cd E:\apache-jmeter-3.2\bin
jmeter -n -t E:\apache-jmeter-3.2\bin\scripts\SampleTestPlan.jmx -l
E:\apache-jmeter-3.2\bin\results\result1.csv -JThread=%thread% -
JRampUp=%rampup% -JLoopCount=%loopcount%
答案 2 :(得分:1)
您也许也可以使用Start
的选项!
@Echo Off
Title Accepting user inputs and passing them to a JMeter Script
Echo Welcome To The World Of Performance Testing.
Set /P "thread=Enter the count for thread groups: "
Set /P "rampup=Enter the ramp up peroid: "
Set /P "loopcount=Enter the loopcount: "
Set "jmdir=E:\apache-jmeter-3.2\bin"
Start "" /B /D "%jmdir%" /Wait jmeter -n -t scripts\SampleTestPlan.jmx -l results\result1.csv -JThread=%thread% -JRampUp=%rampup% -JLoopCount=%loopcount%
Pause
答案 3 :(得分:0)
@ user7294900-在我的批处理文件中使用了以下内容-
e:
cd apache-jmeter-3.2\bin
jmeter -n -t E:\apache-jmeter-3.2\bin\scripts\SampleTestPlan.jmx -l E:\apache-jmeter-3.2\bin\results\results1.csv -JThreads=%thread% -JRampUp=%rampup% -JLoopCount=%loopcount%
pause