一键运行JMeter脚本并生成结果

时间:2019-01-22 07:11:06

标签: batch-file jmeter

我需要运行放在XYZ位置的JMeter脚本,然后想为不同的执行运行生成结果日期和时间。我们可以借助 .BAT 文件来做到这一点吗?

如果可以,请协助我。

1 个答案:

答案 0 :(得分:1)

是的,托尼,你当然可以做到。过去,我曾将它用于我的一种脚本,并且有效。粘贴下面的 .bat 文件内容。对于.sh文件,您将需要做一些改动以进行谷歌搜索。 .bat文件的内容如下:

@echo off

set UserProperties="give user.properties file location here"
set SystemProperties="give system.properties file location here"

set /p ThreadGroup=Enter the number of virtual users: 
set /p RampUpTime=Enter the ramp up peroid: 
set /p LoopCount=Enter the loop count value: 
set /p BaseURL=Enter the base URL: 

mkdir local location\TestResult_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%  ---- Make a folder with timestamp appended to store in your result

set Output1="local location\TestResult_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%"

echo User Inputs Entered For The Test Are: >>%Output1%\TestInput_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.txt
echo ThreadGroup=%ThreadGroup% >> %Output1%\TestInput_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.txt
echo RampUpTime=%RampUpTime% >> %Output1%\TestInput_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.txt
echo LoopCount=%LoopCount% >> %Output1%\TestInput_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.txt
echo BaseURL=%BaseURL% >> %Output1%\TestInput_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.txt

echo Test Input File has been placed at %Output1%

e: 
cd apache-jmeter-3.2\bin  ( Go to the bin folder where JMeter is installed)

jmeter -n -t E:\apache-jmeter-3.2\bin\scripts\SampleTestPlan.jmx -l E:\apache-jmeter-3.2\bin\results\TestResult_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%\TestResult_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.csv -j E:\apache-jmeter-3.2\bin\results\TestResult_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%\Testlogs_%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~0,2%%time:~3,2%%time:~6,2%.log -JThreadGroup=%ThreadGroup% -JRampUpTime=%RampUpTime% -JLoopCount=%LoopCount% -JBaseURL=%BaseURL%   ---- Finally run the command to start non gui mode execution.

结果,将在指定位置创建一个文件夹,其中包含输入文件,日志文件和所有结果的 .CSV 文件。