Passing values to JMeter script at run time through bat file

Viewed 1283

I need to pass thread group, ramp up time and loop count to a JMeter script at run-time after getting the inputs from the user.

For this I have created a bat file like below:

@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

But I'm getting the output as below, it's accepting the inputs but I'm unable to launch the command to run Jmeter in non-GUI mode by redirecting to location - E:\apache-jmeter-3.2\bin using the .bat file.

enter image description here

4 Answers

Go to directory of jmeter in script:

 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%

You may be able to use Start's options too!

@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

@user7294900 - Have used below thing in my batch file -

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
Related