Skip to content

Commit

Permalink
Change version 1.3 add export result in html, csv or json format, add…
Browse files Browse the repository at this point in the history
… template html freemarker file
  • Loading branch information
DABURON Vincent committed Jul 6, 2023
1 parent d3a5ea4 commit 214633d
Show file tree
Hide file tree
Showing 14 changed files with 447 additions and 19 deletions.
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generating JUnit Report based on custom Key Performance Indicators (KPIs) applied to the JMeter Dashboard Statistics Json file

This tool read KPI declarations in a file and apply the KPI assertion on a JMeter Dashboard Statistics Json file and generates a result file in JUnit XML format.
This tool read KPI declarations in a file and apply the KPI assertion on a JMeter Dashboard Statistics Json file and generates a result file in JUnit XML format and others formats Html, Json and Csv.

[Manual Dashboard](https://jmeter.apache.org/usermanual/generating-dashboard.html#report)
JMeter Dashboard Statistics Json file could be generated in Command Line Interface (CLI) with :
Expand Down Expand Up @@ -41,19 +41,26 @@ Save in UTF-8 comma separator **no BOM** or csv with comma separator if you have
## Parameters
The tool have parameters :
<pre>
usage: io.github.vdaburon.jmeter.utils.jsonkpi.JUnitReportFromJMDashboardStats [-exitReturnOnFail &lt;exitReturnOnFail&gt;] [-help] -jsonStats &lt;jsonStats&gt;
usage: io.github.vdaburon.jmeter.utils.jsonkpi.JUnitReportFromJMDashboardStats [-csvOutFile &lt;csvOutFile&gt;] [-divHtmlOutFile &lt;divHtmlOutFile&gt;]
[-exitReturnOnFail &lt;exitReturnOnFail&gt;] [-help] [-htmlOutFile &lt;htmlOutFile&gt;] [-jsonOutFile &lt;jsonOutFile&gt;] -jsonStats &lt;jsonStats&gt;
[-junitFile &lt;junitFile&gt;] -kpiFile &lt;kpiFile&gt;
io.github.vdaburon.jmeter.utils.jsonkpi.JUnitReportFromJMDashboardStats
-csvOutFile &lt;csvOutFile&gt; Csv out file result optional (E.g: result.csv)
-divHtmlOutFile &lt;divHtmlOutFile&gt; Div Partial Html Page out file result optional (E.g: div_result.html), to include in an another HTML
Page
-exitReturnOnFail &lt;exitReturnOnFail&gt; 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 &lt;htmlOutFile&gt; Html out file result optional (E.g: result.html)
-jsonOutFile &lt;jsonOutFile&gt; Json out file result optional (E.g: result.json)
-jsonStats &lt;jsonStats&gt; JMeter Dashboard stats file (E.g : statistics.json)
-junitFile &lt;junitFile&gt; junit file name out (Default : jmeter-junit-plugin-jmstats.xml)
-kpiFile &lt;kpiFile&gt; KPI file contains rule to check (E.g : kpi.csv)
E.g : java -jar junit-reporter-kpi-from-jmeter-dashboard-stats-&lt;version&gt;-jar-with-dependencies.jar -jsonStats statistics.json -kpiFile
kpi.csv -exitReturnOnFail true
or more parameters : java -jar junit-reporter-kpi-from-jmeter-dashboard-stats-&lt;version&gt;-jar-with-dependencies.jar -jsonStats statistics.json
-kpiFile kpi_check.csv -junitFile junit.xml -exitReturnOnFail true
-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
Expand Down Expand Up @@ -89,6 +96,18 @@ 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>
![junit jenkins build detail fail](doc/images/junit_report_jenkins_detail_fail.png)

## Html out format
The result could be a html page ou partial html page (div)
![html out format](doc/images/html_out_result.png)

## Csv out format
The result in a csv file
![csv out format](doc/images/csv_out_result.png)

## Json out format
The result in a Json file
![csv out format](doc/images/json_out_result.png)

## License
See the LICENSE file Apache 2 [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)

Expand All @@ -98,7 +117,7 @@ The maven groupId, artifactId and version, this plugin is in the **Maven Central
```xml
<groupId>io.github.vdaburon</groupId>
<artifactId>junit-reporter-kpi-from-jmeter-dashboard-stats</artifactId>
<version>1.2</version>
<version>1.3</version>
```
Just include the plugin in your `pom.xml` and execute `mvn verify` <br>
or individual launch `mvn -DjsonStats=statistics.json -DkpiFile=kpi.csv -DjunitFile=jmeter-junit-plugin-jmstats.xml exec:java@create_junit-report-kpi-from-jmeter-json-statics`
Expand All @@ -117,7 +136,7 @@ or individual launch `mvn -DjsonStats=statistics.json -DkpiFile=kpi.csv -DjunitF
<dependency>
<groupId>io.github.vdaburon</groupId>
<artifactId>junit-reporter-kpi-from-jmeter-dashboard-stats</artifactId>
<version>1.2</version>
<version>1.3</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -167,6 +186,8 @@ Usually this plugin is use with [jmeter-maven-plugin](https://github.com/jmeter-
You could also use [jmeter-graph-tool-maven-plugin](https://github.com/vdaburon/jmeter-graph-tool-maven-plugin)

## Versions
version 1.3 export result in html, json or csv format

Version 1.2 change the Test Suite Name

Version 1.1 change Fail Message when equality
Expand Down
Binary file added doc/images/csv_out_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/html_out_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/json_out_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 23 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

<groupId>io.github.vdaburon</groupId>
<artifactId>junit-reporter-kpi-from-jmeter-dashboard-stats</artifactId>
<version>1.2</version>
<version>1.3</version>
<packaging>jar</packaging>
<name>Create a JUnit XML file with KPI rules from JMeter Dashboard Stats</name>
<description>A tool that creates a JUnit XML file with KPI rules from JMeter JMeter Dashboard stats.json</description>
<description>A tool that creates a JUnit XML file with KPI rules from JMeter JMeter Dashboard stats.json and generates a result file in JUnit XML format and other formats : html, csv and json.</description>
<url>https://github.com/vdaburon/JUnitReportKpiJMeterDashboardStats</url>
<inceptionYear>2023</inceptionYear>

Expand Down Expand Up @@ -64,21 +64,34 @@
</properties>

<dependencies>
<!-- Command Line Parameters -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.5.0</version>
</dependency>

<!-- Read or write CSV file -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.10.0</version>
</dependency>

<!-- HTML out file result -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.5.0</version>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.32</version>
</dependency>

<!-- JSON out file result -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.2</version>
<version>2.15.2</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -160,6 +173,10 @@
</executions>
</plugin>
<plugin>
<!-- deploy jar in maven central or stagging only : mvn clean deploy
if autoReleaseAfterClose == true then release in maven central;
if autoReleaseAfterClose == false then release in stagging only not maven central
-->
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void setThreshold(String threshold) {
public boolean isKpiFail() {
return isKpiFail;
}
// for freemaker, not use is (isKpiFail) but get (getKpiFail)
public boolean getKpiFail() {
return isKpiFail;
}

public void setKpiFail(boolean kpiFail) {
isKpiFail = kpiFail;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.github.vdaburon.jmeter.utils.jsonkpi;

import java.util.List;

public class GlobalResult {
private String jsonJmeterStats;
private String kpiFile;
private int numberOfKpis;
private int numberFailed;
List checkKpiResults;

public String getJsonJmeterStats() {
return jsonJmeterStats;
}

public void setJsonJmeterStats(String jsonJmeterStats) {
this.jsonJmeterStats = jsonJmeterStats;
}

public String getKpiFile() {
return kpiFile;
}

public void setKpiFile(String kpiFile) {
this.kpiFile = kpiFile;
}

public int getNumberOfKpis() {
return numberOfKpis;
}

public void setNumberOfKpis(int numberOfKpis) {
this.numberOfKpis = numberOfKpis;
}

public int getNumberFailed() {
return numberFailed;
}

public void setNumberFailed(int numberFailed) {
this.numberFailed = numberFailed;
}

public List getCheckKpiResults() {
return checkKpiResults;
}

public void setCheckKpiResults(List checkKpiResults) {
this.checkKpiResults = checkKpiResults;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("GlobalResult{");
sb.append("jsonJmeterStats='").append(jsonJmeterStats).append('\'');
sb.append(", kpiFile='").append(kpiFile).append('\'');
sb.append(", numberOfKpis=").append(numberOfKpis);
sb.append(", numberFailed=").append(numberFailed);
sb.append(", checkKpiResults=").append(checkKpiResults);
sb.append('}');
return sb.toString();
}
}
Loading

0 comments on commit 214633d

Please sign in to comment.