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.

Apache Ant

Jmeter

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.

ant1

8) Right click on it and click on edit option.

ant2

9) Search for Djmeter.home and jmeter.home

ant3

ant4

10) On both the places add you Jmeter location like this –

ant5

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)

ant6

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.

ant7

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

ant8

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

ant9

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.

ant10

18) To view the detailed result go to Apache Ant bin folder and search for Test.html file.

ant11

Double click on Test.html to view the detailed result. Result will look like this –

ant12

23 Responses to “Step by step process to run .jmx file through command prompt using Ant and generate HTML report”

  1. Samrat Basra says:

    everything is nice and helpful, but getting error for Test.jtl file. (premature end of file). to resolve this please add below entry in Test.jtl file.

    • Samrat Basra says:

      everything is nice and helpful, but getting error for Test.jtl file. (premature end of file). to resolve this please add this entry in Test.jtl file.

  2. Karthik says:

    Found the solution for fatal error

  3. Praveen says:

    Hi Naveen,

    I am getting below error, any idea what I did wrong?

    C:\apache-ant-1.10.1\bin>ant
    Buildfile: C:\apache-ant-1.10.1\bin\build.xml

    run:
    [echo] funcMode = false
    [jmeter] Executing test plan: C:\apache-ant-1.10.1\bin\Test.jmx ==> C:\apache-ant-1.10.1\bin\Test.jtl

    _message_xalan:

    xslt-report:
    [xslt] Processing C:\apache-ant-1.10.1\bin\Test.jtl to C:\apache-ant-1.10.1\bin\Test.html
    [xslt] Loading stylesheet C:\apache-ant-1.10.1\bin\jmeter-results-detail-report_21.xsl
    [xslt] C:\apache-ant-1.10.1\bin\Test.jtl:1:1: Fatal Error! Content is not allowed in prolog.
    [xslt] Failed to process C:\apache-ant-1.10.1\bin\Test.jtl

    BUILD FAILED
    C:\apache-ant-1.10.1\bin\build.xml:124: Fatal error during transformation using C:\apache-ant-1.10.1\bin\jmeter-results-detail-report_21.xsl: Content is not allowed in prolog.; SystemID: file:/C:/apache-ant-1.10.1/bin/Test.jtl; Line#: 1; Column#: 1

    Total time: 4 seconds

    C:\apache-ant-1.10.1\bin>

    • chuong says:

      Hi, I am encounter the same error despite followed the exact steps. Have you solved your error? If yes, can you please help. Thanks.

  4. Ross says:

    Very useful. Thanks much

  5. Hussain says:

    Hello Naveen,
    I want to create a separate html file at each run. May be by adding/appending timestamp for each html file.
    Looks like when we run ‘ant’ it deletes the existing html file. Can you share some insight for the same so for each ant run it generates a new html file keeping the old one as it is?

  6. Divyashri Somayaji says:

    I followed all the steps but i got this error..
    BUILD FAILED
    C:\apache-ant-1.10.0\bin\build.xml:87: Reference C:\jmeter\extras\ant-jmeter-1.1
    .1.jar not found.

    Total time: 0 seconds
    I installed ant-jmeter-1.1.1.jar file and kept in extras folder of jmeter..
    Still i am getting the above error..
    Please help..

  7. Suman says:

    Thanks a good sequence of steps…

  8. Priya says:

    Please help with this error
    run:
    [echo] funcMode = false
    [jmeter] Executing test plan: C:\apacheant\bin\Test.jmx ==> C:\apacheant\bin\
    Test.jtl
    _message_xalan:
    xslt-report:
    [xslt] Processing C:\apacheant\bin\Test.jtl to C:\apacheant\bin\Test.html
    [xslt] Loading stylesheet C:\apacheant\bin\jmeter-results-detail-report_21.
    xsl
    [xslt] C:\apacheant\bin\Test.jtl:1:1: Fatal Error! Premature end of file.
    [xslt] Failed to process C:\apacheant\bin\Test.jtl
    BUILD FAILED
    C:\apacheant\bin\build.xml:132: Fatal error during transformation using C:\apach
    eant\bin\jmeter-results-detail-report_21.xsl: Premature end of file.; SystemID:
    file:/C:/apacheant/bin/Test.jtl; Line#: 1; Column#: 1
    Total time: 4 seconds
    Suggest how to fix the issue.Thanks in advance.

  9. SofiaUDueber says:

    What’s up to all, as I am actually eager of reading this blog’s post to be updated
    on a regular basis. It carries nice material.

  10. Alfred Hu says:

    Thanks for your article that help me a lot

  11. EhtelGBosell says:

    Woah! I’m really enjoying the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s quite hard to acquire that “perfect balance” between usability and appearance.
    I must say you might have done a awesome job using this. Also, the blog loads extremely fast for
    me personally on Opera. Superb Blog!

  12. samadhan says:

    an awesome article, Thanks a lot 🙂

  13. Ravi Kumar says:

    Thank you very much

  14. gmail hacker pro 2.9.0 product key says:

    I used to be able to find good advice from your blog posts.

  15. Srinath says:

    Thanks for the detailed steps –
    I have followed similar steps and getting following error – BUILD FAILED

    C:\apacheant\bin>ant
    Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
    Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:”C:\Program Files (x86)\
    HP\Unified Functional Testing\bin\java_shared\classes”;”C:\Program Files (x86)\H
    P\Unified Functional Testing\bin\java_shared\classes\jasmine.jar”
    Buildfile: C:\apacheant\bin\build.xml

    run:
    [echo] funcMode = false
    [jmeter] Executing test plan: C:\apacheant\bin\Test.jmx ==> C:\apacheant\bin\
    Test.jtl

    _message_xalan:

    xslt-report:
    [xslt] Processing C:\apacheant\bin\Test.jtl to C:\apacheant\bin\Test.html
    [xslt] Loading stylesheet C:\apacheant\bin\jmeter-results-detail-report_21.
    xsl
    [xslt] C:\apacheant\bin\Test.jtl:1:1: Fatal Error! Premature end of file.
    [xslt] Failed to process C:\apacheant\bin\Test.jtl

    BUILD FAILED
    C:\apacheant\bin\build.xml:132: Fatal error during transformation using C:\apach
    eant\bin\jmeter-results-detail-report_21.xsl: Premature end of file.; SystemID:
    file:/C:/apacheant/bin/Test.jtl; Line#: 1; Column#: 1

    Total time: 4 seconds

    Could anyone pls. suggest how to fix the issue. appreciate your help at the earliest.

  16. Sen says:

    Im getting the following during the build. I installed Ant and working properly. Any suggestion?

    i.e.

    Buildfile: C:\Users\xxxxxx\Desktop\apache-jmeter-2.13\apache-jmeter-2.13\extras\build.xml

    BUILD FAILED
    C:\Users\xxxxxx\Desktop\apache-jmeter-2.13\apache-jmeter-2.13\extras\build.xml:80: The value of attribute “dir” associated with an element type “null” must not contain t
    he ‘<' character.

    Total time: 0 seconds

  17. Abimbola says:

    Kindly help with this error

    BUILD FAILED
    C:\apache-ant-1.9.6\bin\build.xml:116: Fatal error during transformation using C:\apache-ant-1.9.6\bin\jmeter-results-detail-report_21.xsl: Premature end of file.; SystemID: file:/C:/apache-ant-1.9.6/bin/Test.jtl; Line#: 1; Column#: 1

    Total time: 3 seconds

  18. gokul says:

    Article was too good. Simply simple.

  19. Alankar says:

    This article is very helpful……………Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code