Awesome
Generating JUnit Report based on custom Key Performance Indicators (KPIs) applied to the JMeter Report CSV file
This tool read KPI declarations in a file and apply the KPI assertion on a JMeter Report CSV file and generates a result file in JUnit XML format and others formats Html, Json and Csv.
JMeter Report CSV file is created with Listener :
- Summary Report, documentation at Summary Report
- Aggregate Report, documentation at Aggregate Report
- Synthesis Report, documentation at Synthesis Report
and "Save Table Data" button<br>
JMeter Report CSV could be generated in Command Line Interface (CLI) with :
- JMeterPluginsCMD tool, documentation at JMeterPluginsCMD
- E.g : JMeterPluginsCMD.bat --generate-csv aggregate.csv --input-jtl results.csv --plugin-type AggregateReport
- JMeterPluginsCMD.bat --generate-csv synthesis.csv --input-jtl results.csv --plugin-type SynthesisReport
- jmeter-graph-tool-maven-plugin maven plugin, documentation at jmeter-graph-tool-maven-plugin
Example of a JMeter Report CSV file (Synthesis Report)<br>
The first line contains header column name<br>
The KPI file format
The KPI file need 5 columns :
- name_kpi the name of the KPI also the classname in the Test Case in JUnit
- metric_csv_column_name the column name header in the JMeter Report CSV file (header likes :
# Samples
orAverage
orMin
orMax
or90% Line
orStd. Dev.
orError %
orThroughput
orReceived KB/sec
orAvg. Bytes
orMY_COLUMN_NAME
) - label_regex the Label name in regular expression, label header in the JMeter Report CSV file (E.g :
SC01_P.*
orSC\d+_P.*
orSC01_P01_LOGIN
orSC01_P01_LOGIN|SC01_P02_HOME
or\d+ /.*
) - comparator the comparator
<
or<=
or>
or>=
- threshold the value (for percentage rate use value between 0 and 1, e.g : 0.02 for 2%)
The column separator is ',' for the kpi file
<pre> name_kpi,metric_csv_column_name,label_regex,comparator,threshold Percentiles_90,90% Line,SC\d+_P.*,<=,3000 Percentiles_90 specific pages,90% Line,SC01_P01_LOGIN|SC01_P02_HOME,<=,4000 Average Pages,Average,SC\d+_P.*,<=,2000 Errors rate,Error %,SC\d+_SCRIPT.*,<,0.01 Page Size,Avg. Bytes,SC.*,<=,512000 Max time specific API,Max,"010 /api/user/.+",<=,5000 Number pages,# Samples,SC.*,>,10 </pre>KPI View in Excel<br>
Save in UTF-8 comma separator no BOM or csv with comma separator if you have only ASCII characters (no accent é,è, à ...)
Parameters
The tool have parameters :
<pre> usage: io.github.vdaburon.jmeter.utils.reportkpi.JUnitReportFromJMReportCsv -csvJMReport <csvJMReport> [-csvLabelColumnName <csvLabelColumnName>] [-csvOutFile <csvOutFile>] [-divHtmlOutFile <divHtmlOutFile>] [-exitReturnOnFail <exitReturnOnFail>] [-help] [-htmlOutFile <htmlOutFile>] [-jsonOutFile <jsonOutFile>] [-junitFile <junitFile>] -kpiFile <kpiFile> io.github.vdaburon.jmeter.utils.reportkpi.JUnitReportFromJMReportCsv -csvJMReport <csvJMReport> JMeter report csv file (E.g: summary.csv or aggregate.csv or synthesis.csv) -csvLabelColumnName <csvLabelColumnName> Label Column Name in CSV JMeter Report (Default: Label) -csvOutFile <csvOutFile> Csv out file result optional (E.g: result.csv) -divHtmlOutFile <divHtmlOutFile> Div Partial Html Page out file result optional (E.g: div_result.html), to include in an another HTML Page -exitReturnOnFail <exitReturnOnFail> If true then when kpi fail then create JUnit XML file and program return exit 1 (KO); If false (Default) then create JUnit XML File and exit 0 (OK) -help Help and show parameters -htmlOutFile <htmlOutFile> Html out file result optional (E.g: result.html) -jsonOutFile <jsonOutFile> Json out file result optional (E.g: result.json) -junitFile <junitFile> JUnit XML file name out (Always created, default: TEST-jmeter-junit-plugin-jmreport.xml) -kpiFile <kpiFile> KPI file contains rule to check (E.g: kpi.csv) E.g : java -jar junit-reporter-kpi-from-jmeter-report-csv-<version>-jar-with-dependencies.jar -csvJMReport summary.csv -kpiFile kpi.csv -exitReturnOnFail true or more parameters : java -jar junit-reporter-kpi-from-jmeter-report-csv-<version>-jar-with-dependencies.jar -csvJMReport AggregateReport.csv -csvLabelColumnName Label -kpiFile kpi_check.csv -junitFile junit.xml -htmlOutFile result.html -divHtmlOutFile div_result.html -csvOutFile result.csv -jsonOutFile result.json -exitReturnOnFail false </pre>JUnit Report XML file generated
Example JUnit XML file generated :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<testsuite errors="0" failures="2" name="JUnit Report From JMeter Report Csv" skipped="0" tests="3">
<testcase classname="Percentiles_90" name="90% Line (SC\d+_P.*) <= 30">
<failure message="">Actual value 63.0 exceeds or equals threshold 30.0 for samples matching "SC\d+_P.*"; fail label(s) "SC01_P01_HOME", "SC03_P01_HOME", "SC03_P03_LOGIN", "SC01_P03_LOGIN", "SC03_P04_LINK_STATS", "SC01_P05_LAUNCH_FIND"</failure>
</testcase>
<testcase classname="Average Page One Page" name="Average (SC01_P05_LAUNCH_RECH) <= 60">
<failure message="">Actual value 79.0 exceeds or equals threshold 60.0 for samples matching "SC01_P05_LAUNCH_FIND"; fail label(s) "SC01_P05_LAUNCH_FIND"</failure>
</testcase>
<testcase classname="Error rate" name="Error % (SC.*) < 0.02"/>
</testsuite>
Remark : failure message is limited to 1024 characters, if failure message finished with "..." then the message is voluntarily truncated.
JUnit Report in a Gitlab Pipeline
A JUnit Report with KPIs display in a Gitlab Pipeline<br>
If you click on button "View Details" for Status Fail, you will show the fail message<br>
JUnit Report in Jenkins Build
A JUnit Report with KPIs display in Jenkins Build<br>
If you click on link "Name Test" fail , you will show the fail message<br>
Html out format
The result could be a html page ou partial html page (div)
Csv out format
The result in a csv file
Json out format
The result in a Json file
License
See the LICENSE file Apache 2 https://www.apache.org/licenses/LICENSE-2.0
Usage Maven
The maven groupId, artifactId and version, this plugin is in the Maven Central Repository
<groupId>io.github.vdaburon</groupId>
<artifactId>junit-reporter-kpi-from-jmeter-report-csv</artifactId>
<version>1.6</version>
Just include the plugin in your pom.xml
and execute mvn verify
<br>
or individual launch mvn -DjmeterReportFile=synthesis.csv -DkpiFile=kpi.csv -DjunitFile=jmeter-junit-plugin-jmreport.xml exec:exec@create_junit-report-kpi-from-jmeter-report
<project>
<properties>
<jmeterReportFile>synthesis.csv</jmeterReportFile>
<kpiFile>kpi.csv</kpiFile>
<junitFile>jmeter-junit-plugin-jmreport.xml</junitFile>
</properties>
<dependencies>
<dependency>
<groupId>io.github.vdaburon</groupId>
<artifactId>junit-reporter-kpi-from-jmeter-report-csv</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<!-- individual launch : mvn exec:exec@create_junit-report-kpi-from-jmeter-report -->
<id>create_junit-report-kpi-from-jmeter-report</id>
<phase>verify</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>io.github.vdaburon.jmeter.utils.reportkpi.JUnitReportFromJMReportCsv</argument>
<argument>-kpiFile</argument>
<argument>${project.build.directory}/jmeter/testFiles/${kpiFile}</argument>
<argument>-csvJMReport</argument>
<argument>${project.build.directory}/jmeter/results/${jmeterReportFile}</argument>
<argument>-junitFile</argument>
<argument>${project.build.directory}/jmeter/results/${junitFile}</argument>
<argument>-exitReturnOnFail</argument>
<argument>true</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Simple jar tool
This tool is a java jar, so it's could be use as simple jar (look at Release to download jar file)
<pre> java -jar junit-reporter-kpi-from-jmeter-report-csv-<version>-jar-with-dependencies.jar -csvJMReport summary.csv -kpiFile kpi.csv -junitFile junit-report.xml -exitReturnOnFail true </pre>Tool installed with jmeter-plugins-manager
This tool could be installed with the jmeter-plugins-manager from jmeter.plugins.org.<br> The tool name is : "vdn@github - junit-reporter-kpi-from-jmeter-report-csv tool"
in JMETER_HOME\bin (Windows)
<pre> junit-reporter-kpi-from-jmeter-report-csv.cmd -csvJMReport summary.csv -kpiFile kpi.csv -junitFile junit-report.xml -htmlOutFile result.html -csvOutFile result.csv </pre>or <br> in JMETER_HOME/bin (Linux or MacOS)
<pre> junit-reporter-kpi-from-jmeter-report-csv.sh -csvJMReport summary.csv -kpiFile kpi.csv -junitFile junit-report.xml -htmlOutFile result.html -csvOutFile result.csv </pre>Link to other project
Usually this plugin is use with jmeter-graph-tool-maven-plugin
Versions
version 1.6 change the default freemaker directory for html_templates because same directory and same files name than others tools junit-report-kpi-xxx generate errors
version 1.5 add jmeter-plugins.org installer
version 1.4 export result in html, json or csv format
Version 1.3 change Fail Message when Equality
Version 1.2 change package name (add reportkpi)
Version 1.1 change groupId
Version 1.0 initial version