Skip to content

Commit 214633d

Browse files
author
DABURON Vincent
committed
Change version 1.3 add export result in html, csv or json format, add template html freemarker file
1 parent d3a5ea4 commit 214633d

File tree

14 files changed

+447
-19
lines changed

14 files changed

+447
-19
lines changed

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generating JUnit Report based on custom Key Performance Indicators (KPIs) applied to the JMeter Dashboard Statistics Json file
22

3-
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.
3+
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.
44

55
[Manual Dashboard](https://jmeter.apache.org/usermanual/generating-dashboard.html#report)
66
JMeter Dashboard Statistics Json file could be generated in Command Line Interface (CLI) with :
@@ -41,19 +41,26 @@ Save in UTF-8 comma separator **no BOM** or csv with comma separator if you have
4141
## Parameters
4242
The tool have parameters :
4343
<pre>
44-
usage: io.github.vdaburon.jmeter.utils.jsonkpi.JUnitReportFromJMDashboardStats [-exitReturnOnFail &lt;exitReturnOnFail&gt;] [-help] -jsonStats &lt;jsonStats&gt;
44+
usage: io.github.vdaburon.jmeter.utils.jsonkpi.JUnitReportFromJMDashboardStats [-csvOutFile &lt;csvOutFile&gt;] [-divHtmlOutFile &lt;divHtmlOutFile&gt;]
45+
[-exitReturnOnFail &lt;exitReturnOnFail&gt;] [-help] [-htmlOutFile &lt;htmlOutFile&gt;] [-jsonOutFile &lt;jsonOutFile&gt;] -jsonStats &lt;jsonStats&gt;
4546
[-junitFile &lt;junitFile&gt;] -kpiFile &lt;kpiFile&gt;
4647
io.github.vdaburon.jmeter.utils.jsonkpi.JUnitReportFromJMDashboardStats
48+
-csvOutFile &lt;csvOutFile&gt; Csv out file result optional (E.g: result.csv)
49+
-divHtmlOutFile &lt;divHtmlOutFile&gt; Div Partial Html Page out file result optional (E.g: div_result.html), to include in an another HTML
50+
Page
4751
-exitReturnOnFail &lt;exitReturnOnFail&gt; if true then when kpi fail then create JUnit XML file and program return exit 1 (KO); if false
4852
[Default] then create JUnit XML File and exit 0 (OK)
4953
-help Help and show parameters
54+
-htmlOutFile &lt;htmlOutFile&gt; Html out file result optional (E.g: result.html)
55+
-jsonOutFile &lt;jsonOutFile&gt; Json out file result optional (E.g: result.json)
5056
-jsonStats &lt;jsonStats&gt; JMeter Dashboard stats file (E.g : statistics.json)
5157
-junitFile &lt;junitFile&gt; junit file name out (Default : jmeter-junit-plugin-jmstats.xml)
5258
-kpiFile &lt;kpiFile&gt; KPI file contains rule to check (E.g : kpi.csv)
5359
E.g : java -jar junit-reporter-kpi-from-jmeter-dashboard-stats-&lt;version&gt;-jar-with-dependencies.jar -jsonStats statistics.json -kpiFile
5460
kpi.csv -exitReturnOnFail true
5561
or more parameters : java -jar junit-reporter-kpi-from-jmeter-dashboard-stats-&lt;version&gt;-jar-with-dependencies.jar -jsonStats statistics.json
56-
-kpiFile kpi_check.csv -junitFile junit.xml -exitReturnOnFail true
62+
-kpiFile kpi_check.csv -junitFile junit.xml -htmlOutFile result.html -divHtmlOutFile div_result.html -csvOutFile result.csv -jsonOutFile
63+
result.json -exitReturnOnFail false
5764
</pre>
5865

5966
## JUnit Report XML file generated
@@ -89,6 +96,18 @@ A JUnit Report with KPIs display in Jenkins Build<br>
8996
If you click on link "Name Test" fail , you will show the fail message<br>
9097
![junit jenkins build detail fail](doc/images/junit_report_jenkins_detail_fail.png)
9198

99+
## Html out format
100+
The result could be a html page ou partial html page (div)
101+
![html out format](doc/images/html_out_result.png)
102+
103+
## Csv out format
104+
The result in a csv file
105+
![csv out format](doc/images/csv_out_result.png)
106+
107+
## Json out format
108+
The result in a Json file
109+
![csv out format](doc/images/json_out_result.png)
110+
92111
## License
93112
See the LICENSE file Apache 2 [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
94113

@@ -98,7 +117,7 @@ The maven groupId, artifactId and version, this plugin is in the **Maven Central
98117
```xml
99118
<groupId>io.github.vdaburon</groupId>
100119
<artifactId>junit-reporter-kpi-from-jmeter-dashboard-stats</artifactId>
101-
<version>1.2</version>
120+
<version>1.3</version>
102121
```
103122
Just include the plugin in your `pom.xml` and execute `mvn verify` <br>
104123
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`
@@ -117,7 +136,7 @@ or individual launch `mvn -DjsonStats=statistics.json -DkpiFile=kpi.csv -DjunitF
117136
<dependency>
118137
<groupId>io.github.vdaburon</groupId>
119138
<artifactId>junit-reporter-kpi-from-jmeter-dashboard-stats</artifactId>
120-
<version>1.2</version>
139+
<version>1.3</version>
121140
</dependency>
122141
</dependencies>
123142

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

169188
## Versions
189+
version 1.3 export result in html, json or csv format
190+
170191
Version 1.2 change the Test Suite Name
171192

172193
Version 1.1 change Fail Message when equality

doc/images/csv_out_result.png

19.8 KB
Loading

doc/images/html_out_result.png

52.1 KB
Loading

doc/images/json_out_result.png

52.9 KB
Loading

pom.xml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
<groupId>io.github.vdaburon</groupId>
88
<artifactId>junit-reporter-kpi-from-jmeter-dashboard-stats</artifactId>
9-
<version>1.2</version>
9+
<version>1.3</version>
1010
<packaging>jar</packaging>
1111
<name>Create a JUnit XML file with KPI rules from JMeter Dashboard Stats</name>
12-
<description>A tool that creates a JUnit XML file with KPI rules from JMeter JMeter Dashboard stats.json</description>
12+
<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>
1313
<url>https://github.com/vdaburon/JUnitReportKpiJMeterDashboardStats</url>
1414
<inceptionYear>2023</inceptionYear>
1515

@@ -64,21 +64,34 @@
6464
</properties>
6565

6666
<dependencies>
67+
<!-- Command Line Parameters -->
68+
<dependency>
69+
<groupId>commons-cli</groupId>
70+
<artifactId>commons-cli</artifactId>
71+
<version>1.5.0</version>
72+
</dependency>
73+
74+
<!-- Read or write CSV file -->
6775
<dependency>
6876
<groupId>org.apache.commons</groupId>
6977
<artifactId>commons-csv</artifactId>
7078
<version>1.10.0</version>
7179
</dependency>
80+
81+
<!-- HTML out file result -->
7282
<dependency>
73-
<groupId>commons-cli</groupId>
74-
<artifactId>commons-cli</artifactId>
75-
<version>1.5.0</version>
83+
<groupId>org.freemarker</groupId>
84+
<artifactId>freemarker</artifactId>
85+
<version>2.3.32</version>
7686
</dependency>
87+
88+
<!-- JSON out file result -->
7789
<dependency>
7890
<groupId>com.fasterxml.jackson.core</groupId>
7991
<artifactId>jackson-databind</artifactId>
80-
<version>2.14.2</version>
92+
<version>2.15.2</version>
8193
</dependency>
94+
8295
</dependencies>
8396

8497
<build>
@@ -160,6 +173,10 @@
160173
</executions>
161174
</plugin>
162175
<plugin>
176+
<!-- deploy jar in maven central or stagging only : mvn clean deploy
177+
if autoReleaseAfterClose == true then release in maven central;
178+
if autoReleaseAfterClose == false then release in stagging only not maven central
179+
-->
163180
<groupId>org.sonatype.plugins</groupId>
164181
<artifactId>nexus-staging-maven-plugin</artifactId>
165182
<version>1.6.13</version>

src/main/java/io/github/vdaburon/jmeter/utils/jsonkpi/CheckKpiResult.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public void setThreshold(String threshold) {
5252
public boolean isKpiFail() {
5353
return isKpiFail;
5454
}
55+
// for freemaker, not use is (isKpiFail) but get (getKpiFail)
56+
public boolean getKpiFail() {
57+
return isKpiFail;
58+
}
5559

5660
public void setKpiFail(boolean kpiFail) {
5761
isKpiFail = kpiFail;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package io.github.vdaburon.jmeter.utils.jsonkpi;
2+
3+
import java.util.List;
4+
5+
public class GlobalResult {
6+
private String jsonJmeterStats;
7+
private String kpiFile;
8+
private int numberOfKpis;
9+
private int numberFailed;
10+
List checkKpiResults;
11+
12+
public String getJsonJmeterStats() {
13+
return jsonJmeterStats;
14+
}
15+
16+
public void setJsonJmeterStats(String jsonJmeterStats) {
17+
this.jsonJmeterStats = jsonJmeterStats;
18+
}
19+
20+
public String getKpiFile() {
21+
return kpiFile;
22+
}
23+
24+
public void setKpiFile(String kpiFile) {
25+
this.kpiFile = kpiFile;
26+
}
27+
28+
public int getNumberOfKpis() {
29+
return numberOfKpis;
30+
}
31+
32+
public void setNumberOfKpis(int numberOfKpis) {
33+
this.numberOfKpis = numberOfKpis;
34+
}
35+
36+
public int getNumberFailed() {
37+
return numberFailed;
38+
}
39+
40+
public void setNumberFailed(int numberFailed) {
41+
this.numberFailed = numberFailed;
42+
}
43+
44+
public List getCheckKpiResults() {
45+
return checkKpiResults;
46+
}
47+
48+
public void setCheckKpiResults(List checkKpiResults) {
49+
this.checkKpiResults = checkKpiResults;
50+
}
51+
52+
@Override
53+
public String toString() {
54+
final StringBuilder sb = new StringBuilder("GlobalResult{");
55+
sb.append("jsonJmeterStats='").append(jsonJmeterStats).append('\'');
56+
sb.append(", kpiFile='").append(kpiFile).append('\'');
57+
sb.append(", numberOfKpis=").append(numberOfKpis);
58+
sb.append(", numberFailed=").append(numberFailed);
59+
sb.append(", checkKpiResults=").append(checkKpiResults);
60+
sb.append('}');
61+
return sb.toString();
62+
}
63+
}

0 commit comments

Comments
 (0)