Call JMeter Command in Windows Batch

Q

How to call JMeter command in a Windows batch file? I want to create a single batch job to run JMeter command line multiple times.

✍: FYIcenter.com

A

You can follow this tutorial to create a Windows batch file to run JMeters command line multiple time.

1. Create a batch file, facebook.bat, with these lines:

echo off
set JMETER_BIN=\fyicenter\jmeter\bin\

rem Run test plan with default password
\fyicenter\jmeter\bin\jmeter -n -t Facebook-Login-Test-8.jmx

rem Run test plan with a given password	
\fyicenter\jmeter\bin\jmeter -n -t Facebook-Login-Test-8.jmx -J pw=Abcd1234

rem Run test plan with an another password	
\fyicenter\jmeter\bin\jmeter -n -t Facebook-Login-Test-8.jmx -J pw=facebook

2. Run the batch file, facebook.bat. You see the following:

\fyicenter>facebook.bat

\fyicenter>echo off

Created the tree successfully using Facebook-Login-Test-8.jmx
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary =      4 in 00:00:20 =    0.2/s Avg:  4799 Min:  3004 Max:  6930 Err:  1 (25.00%)
... end of run

3. Notice that Windows only executed the first JMeter command and then terminated the batch job.

4. Copy the batch file to create the 2nd version, facebook2.bat, to fix the problem by using the "call" command:

echo off
set JMETER_BIN=\fyicenter\jmeter\bin\

rem Run test plan with default password
call \fyicenter\jmeter\bin\jmeter -n -t Facebook-Login-Test-8.jmx

rem Run test plan with a given password	
call \fyicenter\jmeter\bin\jmeter -n -t Facebook-Login-Test-8.jmx -J pw=Abcd1234

rem Run test plan with an another password	
call \fyicenter\jmeter\bin\jmeter -n -t Facebook-Login-Test-8.jmx -J pw=facebook

5. Run the second version, facebook2.bat. Now you see all 3 JMeter got executed one after another:

\fyicenter>facebook.bat

\fyicenter>echo off

Created the tree successfully using Facebook-Login-Test-8.jmx
...

Created the tree successfully using Facebook-Login-Test-8.jmx
...

Created the tree successfully using Facebook-Login-Test-8.jmx
...

 

Running JMeter in Command Line Mode

⇒⇒Apache JMeter Tutorials

2017-12-04, 175👍, 0💬