You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/05/25 06:58:08 UTC
[maven-surefire] branch improve-formatted-time-and-percentage-in-report updated (bc5bf78c6 -> e5af74c1c)
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a change to branch improve-formatted-time-and-percentage-in-report
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
discard bc5bf78c6 [SUREFIRE-2166] Use ChoiceFormat to selective render percentage and elapsed time in SurefireReportRenderer
new e5af74c1c [SUREFIRE-2166] Use ChoiceFormat to selective render percentage and elapsed time in SurefireReportRenderer
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (bc5bf78c6)
\
N -- N -- N refs/heads/improve-formatted-time-and-percentage-in-report (e5af74c1c)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/main/resources/surefire-report.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[maven-surefire] 01/01: [SUREFIRE-2166] Use ChoiceFormat to selective render percentage and elapsed time in SurefireReportRenderer
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch improve-formatted-time-and-percentage-in-report
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit e5af74c1c3471c9c51bf5a1ca1ca3556ceda365e
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri May 19 20:05:42 2023 +0200
[SUREFIRE-2166] Use ChoiceFormat to selective render percentage and elapsed time in SurefireReportRenderer
This closes #639
---
.../surefire/report/SurefireReportRenderer.java | 38 ++++++++++------------
.../src/main/resources/surefire-report.properties | 6 ++++
.../main/resources/surefire-report_de.properties | 1 +
.../main/resources/surefire-report_sv.properties | 1 +
.../plugins/surefire/report/Surefire597Test.java | 6 ++--
.../surefire/report/SurefireReportMojoTest.java | 30 ++++++++---------
6 files changed, 43 insertions(+), 39 deletions(-)
diff --git a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java
index 9cf0039a7..75ca805e2 100644
--- a/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java
+++ b/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportRenderer.java
@@ -19,7 +19,6 @@
package org.apache.maven.plugins.surefire.report;
import java.io.File;
-import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -100,6 +99,16 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
return i18n.getString("surefire-report", locale, "report." + section + '.' + key);
}
+ /**
+ * @param section The section.
+ * @param key The key to translate.
+ * @param args The args to pass to translated string.
+ * @return the translated key.
+ */
+ private String formatI18nString(String section, String key, Object... args) {
+ return i18n.format("surefire-report", locale, "report." + section + '.' + key, args);
+ }
+
public void renderBody() {
javaScript(javascriptToggleDisplayCode());
@@ -120,9 +129,6 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
private void renderSectionSummary() {
Map<String, Object> summary = parser.getSummary(testSuites);
- NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
- NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
- percentFormat.setMinimumFractionDigits(1);
sink.section1();
sinkAnchor("Summary");
@@ -150,8 +156,8 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
String.valueOf(summary.get("totalErrors")),
String.valueOf(summary.get("totalFailures")),
String.valueOf(summary.get("totalSkipped")),
- percentFormat.format(summary.get("totalPercentage")),
- numberFormat.format(summary.get("totalElapsedTime")) + " s"
+ formatI18nString("surefire", "value.successrate", summary.get("totalPercentage")),
+ formatI18nString("surefire", "value.time", summary.get("totalElapsedTime"))
});
endTable();
@@ -171,10 +177,6 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
return;
}
- NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
- NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
- percentFormat.setMinimumFractionDigits(1);
-
sink.section1();
sinkAnchor("Package_List");
sink.sectionTitle1();
@@ -210,8 +212,8 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
String.valueOf(packageSummary.get("totalErrors")),
String.valueOf(packageSummary.get("totalFailures")),
String.valueOf(packageSummary.get("totalSkipped")),
- percentFormat.format(packageSummary.get("totalPercentage")),
- numberFormat.format(packageSummary.get("totalElapsedTime")) + " s"
+ formatI18nString("surefire", "value.successrate", packageSummary.get("totalPercentage")),
+ formatI18nString("surefire", "value.time", packageSummary.get("totalElapsedTime"))
});
}
@@ -273,10 +275,6 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
}
private void renderSectionTestSuite(ReportTestSuite suite) {
- NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
- NumberFormat percentFormat = NumberFormat.getPercentInstance(locale);
- percentFormat.setMinimumFractionDigits(1);
-
sink.tableRow();
sink.tableCell();
@@ -310,9 +308,9 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
float percentage = parser.computePercentage(
suite.getNumberOfTests(), suite.getNumberOfErrors(),
suite.getNumberOfFailures(), suite.getNumberOfSkipped());
- tableCell(percentFormat.format(percentage));
+ tableCell(formatI18nString("surefire", "value.successrate", percentage));
- tableCell(numberFormat.format(suite.getTimeElapsed()) + " s");
+ tableCell(formatI18nString("surefire", "value.time", suite.getTimeElapsed()));
sink.tableRow_();
}
@@ -372,8 +370,6 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
}
private void constructTestCaseSection(ReportTestCase testCase) {
- NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
-
sink.tableRow();
sink.tableCell();
@@ -427,7 +423,7 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
sinkCellAnchor(testCase.getName(), "TC_" + toHtmlId(testCase.getFullName()));
}
- tableCell(numberFormat.format(testCase.getTime()) + " s");
+ tableCell(formatI18nString("surefire", "value.time", testCase.getTime()));
sink.tableRow_();
diff --git a/maven-surefire-report-plugin/src/main/resources/surefire-report.properties b/maven-surefire-report-plugin/src/main/resources/surefire-report.properties
index 2b68fbb02..ba45d6306 100644
--- a/maven-surefire-report-plugin/src/main/resources/surefire-report.properties
+++ b/maven-surefire-report-plugin/src/main/resources/surefire-report.properties
@@ -35,6 +35,12 @@ report.surefire.label.testcases=Test Cases
report.surefire.label.failuredetails=Failure Details
report.surefire.text.note1=Note: failures are anticipated and checked for with assertions while errors are unanticipated.
report.surefire.text.note2=Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
+report.surefire.value.successrate={0,choice,0#0%|0.0<{0,number,0.0%}|1#{0,number,0%}}
+# Rationale: The idea is to always display four digits for visually consistent output
+# Important:
+# * Keep in sync with org.apache.maven.plugin.surefire.report.WrappedReportEntry
+# * Needs to be copied into other bundles only if non-Latin script is used
+report.surefire.value.time={0,choice,0#0|0.0<{0,number,0.000}|10#{0,number,0.00}|100#{0,number,0.0}|1000#{0,number,0}} s
report.failsafe.name=Failsafe
report.failsafe.description=Report on the integration test results of the project.
diff --git a/maven-surefire-report-plugin/src/main/resources/surefire-report_de.properties b/maven-surefire-report-plugin/src/main/resources/surefire-report_de.properties
index 2a3bb905e..2867ac5d2 100644
--- a/maven-surefire-report-plugin/src/main/resources/surefire-report_de.properties
+++ b/maven-surefire-report-plugin/src/main/resources/surefire-report_de.properties
@@ -35,6 +35,7 @@ report.surefire.label.tests=Tests
report.surefire.label.time =Zeit
report.surefire.text.note1 =Hinweis: Fehlschl\u00E4ge werden erwartet und durch Behauptungen \u00FCberpr\u00FCft w\u00E4hrend Fehler unerwartet sind.
report.surefire.text.note2 =Hinweis: Die Paketstatistiken werden nicht rekursiv berechnet, es werden lediglich die Ergebnisse aller enthaltenen Tests aufsummiert.
+report.surefire.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}}
report.failsafe.name=Failsafe
report.failsafe.description=Bericht \u00FCber die Integrationstestresultate des Projekts.
diff --git a/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties b/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties
index 3b60a603c..d1b69679b 100644
--- a/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties
+++ b/maven-surefire-report-plugin/src/main/resources/surefire-report_sv.properties
@@ -35,6 +35,7 @@ report.surefire.label.testcases=Testfall
report.surefire.label.failuredetails=Detaljer om misslyckade tester
report.surefire.text.note1=Notera: misslyckade tester \u00e4r f\u00f6rv\u00e4ntade och har kontrollerats med assertions medan felaktiga tester \u00e4r ov\u00e4ntade.
report.surefire.text.note2=Notera: paketstatistiken ber\u00e4knas inte rekursivt, den summerar bara alla testsviters antal.
+report.surefire.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}}
report.failsafe.name=Failsafe
report.failsafe.description=Rapport om integration testresultaten f\u00f6r projektet.
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java
index f1a45fdc2..598c91678 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java
@@ -66,7 +66,7 @@ public class Surefire597Test extends TestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td>"
+ "</tr>"
+ "</table>")));
@@ -87,7 +87,7 @@ public class Surefire597Test extends TestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr></table>")));
assertThat(
xml,
@@ -108,7 +108,7 @@ public class Surefire597Test extends TestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr></table>")));
assertThat(
xml,
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
index 1b2634aaf..8dab21e86 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportMojoTest.java
@@ -193,7 +193,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td>")));
assertThat(
@@ -204,7 +204,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(
htmlContent,
@@ -219,7 +219,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest:13</a>"));
@@ -281,7 +281,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td>")));
assertThat(
@@ -292,7 +292,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(
htmlContent,
@@ -307,7 +307,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest:13</a>"));
@@ -344,7 +344,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td>")));
assertThat(
@@ -355,7 +355,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(
htmlContent,
@@ -370,7 +370,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest:13</a>"));
@@ -432,7 +432,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td>")));
assertThat(
@@ -443,7 +443,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(
htmlContent,
@@ -458,7 +458,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest$A:45</a>"));
@@ -495,7 +495,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td>")));
assertThat(
@@ -506,7 +506,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(
htmlContent,
@@ -521,7 +521,7 @@ public class SurefireReportMojoTest extends AbstractMojoTestCase {
+ "<td>1</td>\n"
+ "<td>0</td>\n"
+ "<td>0</td>\n"
- + "<td>0.0%</td>\n"
+ + "<td>0%</td>\n"
+ "<td>0 s</td></tr>")));
assertThat(htmlContent, containsString(">surefire.MyTest$A:45</a>"));