
JMeter HTML Dashboard Report Generation
JMeter HTML Dashboard Report Generation
Steps to Generate Proper JMeter HTML Dashboard Report:- While creating a Test Script for a Test Scenario in JMeter, the best practice is to put each group of Samplers for a particular Transaction (or a User Action) inside a respective Transaction Controller (also, by default when we go for recording in JMeter, it gives us this option to put each group of Samplers in a Transaction Controller), and performing “Apply Naming Policy” action for all the Samplers inside each Transaction Controllers. But doing this in our Test Script, we face challenges in proper JMeter HTML Dashboard Report generation, and many people does not have a clear idea how to generate a proper HTML Report which shows only Transaction Controllers and also all Graphs are displayed properly. In this article, we will address this challenge. N.B.:-
- It is mandatory (as well as recommended) that the two Checkboxes in all the Transaction Controllers used in Test Script must NOT be checked (also, by default they are not checked as well).
- Its mandatory (as well as recommended) to perform “Apply Naming Policy” action for each group of Samplers inside each respective Transaction Controllers by “right clicking” on each Transaction Controllers.
- Always, remember to Restart the JMeter whenever we do any changes in any of the six“properties” file or any “bat” file in the “bin” folder so that changes can take place in JMeter GUI. Also, remember to Restart JMeter if we do any changes in “lib” folder or “lib -> ext” folder in JMeter directory for the changes to take place.
- Also remember, while running a Test in JMeter, either in Non-GUI mode or GUI mode, it’s always recommended to disable the unnecessary Elements of that Test Plan/Script.
- Always remember to use “Backslash” (i.e. “/ ”) while giving File path or Directory path everytimein JMeter wherever required, because JMeter generally recognise the “Forward slash” (i.e. “ \ ”) as Escape Character.
There is no such pre-defined changes that needs to be applied or remembered for HTML Report generation. Here, we will start with a Fresh Copy of JMeter, v5.1.1, downloaded from Internet. In addition, we are using “JPetStore.jmx” Test Plan in JMeter, with each group of Samplers inside a respective Transaction Controller.Illustration goes as:-
Note: – If you Select the option “Generate parent sample” in Transaction Controller, and runthe test from Non-GUI mode, you will notsee the Test Summary. Test will execute, but Test Summary will not come. Case-1:- In Non-GUI Mode, Proper Generation of HTML Report Step-1:- Download a fresh copy of JMeter. Goto to “bin” folder and open “user.properties” file using Notepad or Notepad++.Then goto the column “Reporting configuration” in this file. Only make below highlighted four lines of changes in this file (note, all other settings are at their place by default, no changes is required in them):-
We need to change these four-highlighted lines from Default value to our Desired value:- Lines with Default Value:– #jmeter.reportgenerator.overall_granularity=60000 #jmeter.reportgenerator.apdex_satisfied_threshold=500 #jmeter.reportgenerator.apdex_tolerated_threshold=1500 #jmeter.reportgenerator.exporter.html.series_filter=^(Search|Order)(-success|-failure)?$ Above Lines with Changed Value:– jmeter.reportgenerator.overall_granularity=1000 jmeter.reportgenerator.apdex_satisfied_threshold=500 jmeter.reportgenerator.apdex_tolerated_threshold=1500 jmeter.reportgenerator.exporter.html.series_filter=^(01_Launch_HomePage|02_Select_Any_Animal|03_Select_A_Type|04_Select_A_Sub_Type|05_Clicking_AddToCart|Dashboard_Report_Generation)(-success|-failure)?$ 1sthighlighted line is about Granularity. This value should never be less than 1 Sec (or 1000 ms). When we run the test for small duration, in that case, we have to make it 1000 (i.e. 1000 ms or 1 Sec) so that all Graphs can come correctly.In case, if we are running the endurance test, i.e. long hour test, then we need to put this value to 60000, (it means 1 minutes, 60 Sec, or 60,000 millisec). 2nd and 3rdhighlighted line is about Satisfied and Tolerated Threshold. These two values depends on your Application’s NFR or value given as per your Client or Benchmarked value. 4thhighlighted line is for Series Filter. Here, we have to give all the Transactions Controller names from our Test Plan, which we want to show in our HTML Report. You can give all Transactions Controller names. To get these Transaction Controller names from our Test Plan easily, go to “Tools” in JMeter with that Test Plan, and then click on option “Export transactions for report”. We have to copy the whole lines and paste it in the above 4thhighlighted line as it is, replacing the existing line. If you wish to remove some Transaction Controllers, we can remove them by not including them in this line. Illustration goes as:-
In addition, you can add a few more lines in this “user.properties”file under the column “Reporting configuration”as per your convenience like as below, (but, Note that,addingthese below lines are NOT necessary for Report Generation, only above 4 lines are enough):- #If you wish to give your own name to Dashboard Report, then:- jmeter.reportgenerator.report_title=JPetStore JMeter Dashboard Report #If you wish to change the time format of “Start Time” and “End Time” in Report, then:- jmeter.save.saveservice.timestamp_format=dd-MM-yyyy HH:mm:ss Save this “user.properties” file after above changes. Step-2:-Set the Number of Users, Duration (or Loop Count), and Startup Delay in the “Thread Group” of your Test Plan and save it. Run your test in Non-GUI mode using command prompt and generate the “csv” result file. Command used for this goes as- >jmeter -n -t JPetStore.jmx -l JPetStore.csv Next, use the above generated “csv” result file to generate the HTML Dashboard Report. Command used for this goes as- >jmeter -g JPetStore.csv -o JPetStore The HTML Dashboard report will be generated in the folder “JPetStore”. Now, open the “index” file inside this folder using Google Chrome (as Google Chrome supports the best) and navigate through different graphs present on left side of the Report. You will get all the Graphs generated properly. Also, all the values in tabular column on the Dashboard page will be in correct state. Case-2:- In Non-GUI Mode, Proper Generation of HTML Report When You Do Not Want To Change 4th Highlighted Line in Above Case Each Time In most cases, when we have multiple Test Plan/Scripts, then it is impractical to change the “user.properties” file each time for each Test Plan while executing them. From above Case-1, out of 4 highlighted lines, first above 3 lines will remain constant for a particular Project, but 4th Line, i.e. Series Filter, needs to be changed while executing each Test Plan, and doing this is very hectic and impractical. To solve this challenge, we have two ways:- 1st) Either created “user.properties” file for each Test Plan/Script and keep them in a Folder, and pass each as parameter while doing command-line execution in Non-GUI mode for each respective Test Plan/Script execution. 2nd) Or, we will follow the same steps from Case-1, and do some changes in “user.properties” file. Referring to Step-1 from Case-1, we will do following highlighted changes:-
We need to have a precise look here, the lines that needs to be changed here are also Four in number, only difference is, first above 3 Lines from Case-1 remains same, but, 4th Line from Case-1 is not included (or enabled) here, instead of that, another line is enabled. We need to change these four-highlighted lines from Default value to our Desired value:- Lines with Default Value:– #jmeter.reportgenerator.overall_granularity=60000 #jmeter.reportgenerator.apdex_satisfied_threshold=500 #jmeter.reportgenerator.apdex_tolerated_threshold=1500 #jmeter.reportgenerator.exporter.html.series_filter=^(Search|Order)(-success|-failure)?$: It’s not included #jmeter.reportgenerator.exporter.html.show_controllers_only=false Above Lines (except 4th Line) with Changed Value:– jmeter.reportgenerator.overall_granularity=1000 jmeter.reportgenerator.apdex_satisfied_threshold=500 jmeter.reportgenerator.apdex_tolerated_threshold=1500 jmeter.reportgenerator.exporter.html.show_controllers_only=true Save this “user.properties” file after above changes, and perform Step-2 of Case-1. We will get all the values and Graphs properly, except one Graph. The “Total Transactions Per Second” Graph will not be having any data/values to show, means this graph will not be coming. Also, there will be some change in “Time Vs Threads” Graph transaction names. So, these 2 Challenges will be coming for this Case-2. As a Solution for this, only thing left is we have to ignore these 2 challenges till JMeter team fixes it. Case-3:- In GUI Mode, Generation of HTML Report Many times, we develop Unit Test Scripts for each small Test Scenarios, and we run those unit Test Scripts from GUI mode only for 1 to 5 users to check for stabilization and debugging. So, we come up with the need to generate the HTML Dashboard Report from GUI mode, instead of Non-GUI mode to save some time. In this Case-3, we will see 2 ways to generate HML Report from GUI Mode. Also, note that, for Report generation, we need “user.properties” file, and wehave to do few changes in this “user.properties” file depending on our requirement and following the steps from either of above 2 Cases, i.e. Case-1 or Case-2. Way-1:- Step-1:- Do the necessary changes in “user.properties” file,and restart the JMeter. Then open your Test Plan/Script. Step-2:-Add a “Simple Data Writer” in your Test Plan at Thread Group Level. Give a Filename with Proper Path in it with extension “.csv”. (Note that you do not need to create any such file by yourself, you just need to give filepath in this field with “.csv” extension. JMeter will automatically create the file and save data to it).Then, click on “Configure” button. Select all the Checkboxes in it, except the 1st one, i.e. “Save as XML”. Illustration goes as:-
Step-3:-Save your Test Plan after all the above changes. Then, Run your Test in GUI Mode. Step-4:- After, running of Test is done, there will be a “csv” file created in the Filepath given in “SimpleData Writer”. Now, you need to click on “Tools” and select “Generate HTML report”. Then, a window will pop-up and ask for 3 inputs. First input is for the “csv” file created in above step. Second inputis for the “user.properties”file that you want to use for Report generation and has all your settings done in it. Third input is for the Output Folder/Directory where you want to save the generated HTML Report. We need to carefully pass all these 3 inputs. Then we have to click on “Generate report” option. This will generate the report in the Output Folder/Directory path that you have given. Illustration goes as:-
That’s all, itsdone. Way-2:- Step-1:-It remains same as of above Step-1 in Way-1, please refer it. Step-2:-It remains same as of above Step-2 in Way-1, please refer it. Step-3:-Add a “teardown Thread Group” in your Test Plan at Test Plan Level. Add a “BeanShell Sampler” inside it. Then add below codein it (this is only for Windows OS):- Runtime.getRuntime().exec( “C:/Windows/System32/cmd.exe /c jmeter -gC:/Users/vallabhk/Desktop/JMeterProjects/JPetStore/TestResults/5_Users.csv-oC:/Users/vallabhk/Desktop/JMeterProjects/JPetStore/TestResults/5_Users“); ** Note that the 1st highlighted part in yellow color is for the CSV result filewith proper filepath that you have given in “Simple Data Writer” in Step-2, and 2nd highlighted part in yellow color is for the Folder/Directory path where you wish to store the generated HTML Report. Illustration goes as:-
Step-4:-Save your Test Plan after all the above changes. Then, Run your Test in GUI Mode. After test is finished, you will get the HTML Report generated automatically by JMeter in the Result Folder/Directory that you have given. That’s all, its done. Isha training solutions is offering ” Jmeter Core to Master” level course. For complete details, pls follow below link JMeter Core to Master Level Course Content



