Step by step process to run .jmx file through command prompt using Ant and generate HTML report
After struggling a lot I came on final conclusion that how we can run .jmx files using Ant and generate HTML report.
Here is step by step process:
Before I start the configuration just want to make sure you have following software downloaded and handy with you.
Java 1.6 or next version of it.
Now follow each step to complete the configuration and run the .jmx file using apache ant.
1) Download and install Java in your system. Once Java will get installed a folder will be created in in C drive under Program Files. C:\Program Files\Java
2) Download Apache Ant and unzip it. Copy the complete unzipped folder to C:\ drive.
3) Download Jmeter and unzip it. Similarly copy the unzipped folder to C:\ drive.
Now you have Java installed, Apache Ant and Jmeter copied to the C:\ drive.
4) Open Jmeter folder and then open Extras folder shown inside Jmeter forlder : C:\apache-jmeter-2.13\extras.
5) Select all the files inside extras folder and copy it. You can use Ctrl+A and then Ctrl+C command to select all and copy.
6) Open Apache Ant and got to bin folder C:\apacheant\bin and paste all the copied files in it. (I have renamed Apache And folder as apacheant so don’t be confused)
7) Once copied all the files in C:\apacheant\bin folder search for build.xml file.
8) Right click on it and click on edit option.
9) Search for Djmeter.home and jmeter.home
10) On both the places add you Jmeter location like this –
11) Save the changes.
12) In Apache Ant bin folder create one text file and name it as Test.jtl
You can create text document by right clicking inside bin folder and selecting text document. Right click -> New -> Text document.
Rename the text doc as Test.jtl (jtl is file extension)
Here you are almost set with all the changes. Now we will run the Test.jmx file which is already available in Apache Ant bin folder as you copied all the items from Jmeter extras folder.
You can change the Test.jmx file with your own jmx but here this is just an example so I have taken the existing Test.jmx file.
Remember if you are changing the Test.jmx file with your own jmx file you need to update the same name in build.xml
13) Open command prompt in admin mode. You can open it by clicking on Start button and then type cmd in search box. Right click on cmd.exe and click on Run as administrator.
14) While running in admin mode will ask you to inter your system password if any. If asks please enter the system password and then click on ok.
15) Type command cd (Your Apache Ant bin folder location) and hit enter button.
Ex: cd C:\apacheant\bin
16) Type set path=(Path of you java bin folder) and hit enter button.
Ex : set path= C:\Program Files\Java\jre1.8.0_40\bin
17) Type ant and hit enter button from you keyboard.
Once you hit enter you build will start running and you can view the result as BUILD SUCCESSFUL at the bottom.
18) To view the detailed result go to Apache Ant bin folder and search for Test.html file.
Double click on Test.html to view the detailed result. Result will look like this –