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/24 13:34:02 UTC
[maven-surefire] branch stacked-fixes updated (6605457df -> 7f67bcae3)
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a change to branch stacked-fixes
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
omit 6605457df Use typographically correct en dash approximations
omit 0ce07d1a7 Improve string representation of elapsed time
omit 79e55141d [SUREFIRE-2164] Simplify serialization of elapsed time in XML reporter
add 4e6a85d36 Remove duplicate license header
add 3580f849d Remove unused dependency
add e27ff1453 Simplify link creation
add 2d739c24f [MNG-6829] Replace StringUtils#isEmpty(String) & #isNotEmpty(String) (#641)
add c49b2b728 [SUREFIRE-2165] TestSuiteXmlParser does not capture text per element causing concatenated text produced
new af2adf0d0 [SUREFIRE-2164] Simplify serialization of elapsed time in XML reporter
new 9921529f2 Improve string representation of elapsed time
new 7f67bcae3 Use typographically correct en dash approximations
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 (6605457df)
\
N -- N -- N refs/heads/stacked-fixes (7f67bcae3)
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 3 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:
.../report/AbstractSurefireReportMojo.java | 3 +--
.../surefire/report/SurefireReportRenderer.java | 4 ++--
.../stubs/DependencyArtifactStubFactory.java | 23 ----------------------
surefire-report-parser/pom.xml | 4 ----
.../surefire/report/TestSuiteXmlParser.java | 9 +++++++++
5 files changed, 12 insertions(+), 31 deletions(-)
[maven-surefire] 02/03: Improve string representation of elapsed time
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch stacked-fixes
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 9921529f2c0189d92507c8dc13f33f2c53e4a9fa
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri May 19 19:57:27 2023 +0200
Improve string representation of elapsed time
---
.../plugin/surefire/report/ReporterUtils.java | 44 ----------------------
.../plugin/surefire/report/WrappedReportEntry.java | 16 ++++++--
.../surefire/report/WrappedReportEntryTest.java | 2 +-
3 files changed, 13 insertions(+), 49 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ReporterUtils.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ReporterUtils.java
deleted file mode 100644
index a673a18d0..000000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ReporterUtils.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugin.surefire.report;
-
-import java.text.NumberFormat;
-import java.util.Locale;
-
-/**
- * Utility for reporter classes.
- *
- * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
- * @since 2.19
- */
-final class ReporterUtils {
- private static final int MS_PER_SEC = 1000;
-
- private ReporterUtils() {
- throw new IllegalStateException("non instantiable constructor");
- }
-
- static String formatElapsedTime(double runTime) {
- NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
- numberFormat.setGroupingUsed(true);
- numberFormat.setMinimumFractionDigits(0);
- numberFormat.setMaximumFractionDigits(3);
- return numberFormat.format(runTime / MS_PER_SEC);
- }
-}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
index 97b3734c2..910c819d2 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
@@ -20,7 +20,9 @@ package org.apache.maven.plugin.surefire.report;
import javax.annotation.Nonnull;
+import java.text.MessageFormat;
import java.util.Collections;
+import java.util.Locale;
import java.util.Map;
import org.apache.maven.surefire.api.report.ReportEntry;
@@ -29,7 +31,6 @@ import org.apache.maven.surefire.api.report.StackTraceWriter;
import org.apache.maven.surefire.api.report.TestSetReportEntry;
import static java.util.Collections.unmodifiableMap;
-import static org.apache.maven.plugin.surefire.report.ReporterUtils.formatElapsedTime;
import static org.apache.maven.surefire.api.util.internal.StringUtils.NL;
import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
@@ -37,6 +38,8 @@ import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
* @author Kristian Rosenvold
*/
public class WrappedReportEntry implements TestSetReportEntry {
+ private static final float ONE_SECOND = 1000.0f;
+
private final ReportEntry original;
private final ReportEntryType reportEntryType;
@@ -49,6 +52,11 @@ public class WrappedReportEntry implements TestSetReportEntry {
private final Map<String, String> systemProperties;
+ // The idea is to always display four digits for visually consistent output
+ private final MessageFormat elapsedTimeFormat = new MessageFormat(
+ "{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",
+ Locale.ROOT);
+
public WrappedReportEntry(
ReportEntry original,
ReportEntryType reportEntryType,
@@ -140,7 +148,7 @@ public class WrappedReportEntry implements TestSetReportEntry {
}
public String elapsedTimeAsString() {
- return formatElapsedTime(getElapsed());
+ return getElapsed() != null ? elapsedTimeFormat.format(new Object[] {getElapsed() / ONE_SECOND}) : null;
}
String getReportSourceName() {
@@ -165,13 +173,13 @@ public class WrappedReportEntry implements TestSetReportEntry {
public String getOutput(boolean trimStackTrace) {
String outputLine =
- getElapsedTimeSummary() + " <<< " + getReportEntryType().name() + "!";
+ getElapsedTimeSummary() + " <<< " + getReportEntryType().name() + "!";
String trimmedStackTrace = getStackTrace(trimStackTrace);
return trimmedStackTrace == null ? outputLine : outputLine + NL + trimmedStackTrace;
}
public String getElapsedTimeVerbose() {
- return "Time elapsed: " + elapsedTimeAsString() + " s";
+ return "Time elapsed: " + (getElapsed() != null ? elapsedTimeAsString() : "(unknown)");
}
public String getElapsedTimeSummary() {
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java
index 0e08294a9..97e1b4cca 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java
@@ -78,7 +78,7 @@ public class WrappedReportEntryTest extends TestCase {
assertNull(wr.getStackTraceWriter());
assertEquals("surefire.testcase.JunitParamsTest.testSum Time elapsed: 0.012 s", wr.getElapsedTimeSummary());
assertEquals(
- "surefire.testcase.JunitParamsTest.testSum Time elapsed: 0.012 s <<< ERROR!", wr.getOutput(false));
+ "surefire.testcase.JunitParamsTest.testSum Time elapsed: 0.012 s <<< ERROR!", wr.getOutput(false));
assertEquals("exception", wr.getMessage());
}
[maven-surefire] 03/03: Use typographically correct en dash approximations
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch stacked-fixes
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 7f67bcae3b83887dc5287ebab49cd451eb2eae7d
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri May 19 21:25:19 2023 +0200
Use typographically correct en dash approximations
https://en.wikipedia.org/wiki/Dash#Approximating_the_em_dash_with_two_or_three_hyphens
---
.../extensions/junit5/JUnit5StatelessTestsetInfoReporter.java | 2 +-
.../java/org/apache/maven/plugin/surefire/report/TestSetStats.java | 2 +-
.../org/apache/maven/plugin/surefire/report/WrappedReportEntry.java | 2 +-
.../apache/maven/plugin/surefire/report/WrappedReportEntryTest.java | 6 +++---
.../maven/surefire/extensions/StatelessTestsetInfoReporterTest.java | 2 +-
.../java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java | 2 +-
.../java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java | 2 +-
.../maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java | 4 ++--
.../its/jiras/Surefire747MethodParallelWithSuiteCountIT.java | 4 +++-
9 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5StatelessTestsetInfoReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5StatelessTestsetInfoReporter.java
index ef44a7755..77987e690 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5StatelessTestsetInfoReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5StatelessTestsetInfoReporter.java
@@ -56,7 +56,7 @@ public class JUnit5StatelessTestsetInfoReporter extends SurefireStatelessTestset
/**
* Phrased class name of test case in the log (see xxx)
- * <em>Tests run: ., Failures: ., Errors: ., Skipped: ., Time elapsed: . s, - in xxx</em>.
+ * <em>Tests run: ., Failures: ., Errors: ., Skipped: ., Time elapsed: . s, -- in xxx</em>.
* {@code false} by default.
* <br>
* This action takes effect only in JUnit5 provider together with a test class annotated <em>DisplayName</em>.
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
index 6e79000dc..96b4fb451 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
@@ -41,7 +41,7 @@ public class TestSetStats {
private static final String ERRORS = "Errors: ";
private static final String SKIPPED = "Skipped: ";
private static final String FAILURE_MARKER = " <<< FAILURE!";
- private static final String IN_MARKER = " - in ";
+ private static final String IN_MARKER = " -- in ";
private static final String COMMA = ", ";
private final Queue<WrappedReportEntry> reportEntries = new ConcurrentLinkedQueue<>();
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
index 910c819d2..31b8141a5 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
@@ -184,7 +184,7 @@ public class WrappedReportEntry implements TestSetReportEntry {
public String getElapsedTimeSummary() {
String description = getName() == null ? getSourceName() : getClassMethodName();
- return description + " " + getElapsedTimeVerbose();
+ return description + " -- " + getElapsedTimeVerbose();
}
public boolean isErrorOrFailure() {
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java
index 97e1b4cca..6d337467a 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/WrappedReportEntryTest.java
@@ -76,9 +76,9 @@ public class WrappedReportEntryTest extends TestCase {
assertTrue(wr.isErrorOrFailure());
assertFalse(wr.isSkipped());
assertNull(wr.getStackTraceWriter());
- assertEquals("surefire.testcase.JunitParamsTest.testSum Time elapsed: 0.012 s", wr.getElapsedTimeSummary());
+ assertEquals("surefire.testcase.JunitParamsTest.testSum -- Time elapsed: 0.012 s", wr.getElapsedTimeSummary());
assertEquals(
- "surefire.testcase.JunitParamsTest.testSum Time elapsed: 0.012 s <<< ERROR!", wr.getOutput(false));
+ "surefire.testcase.JunitParamsTest.testSum -- Time elapsed: 0.012 s <<< ERROR!", wr.getOutput(false));
assertEquals("exception", wr.getMessage());
}
@@ -147,6 +147,6 @@ public class WrappedReportEntryTest extends TestCase {
ReportEntry reportEntry = new SimpleReportEntry(NORMAL_RUN, 1L, className, null, null, null);
WrappedReportEntry wr = new WrappedReportEntry(reportEntry, null, 12, null, null);
String elapsedTimeSummary = wr.getElapsedTimeSummary();
- assertEquals("[0] 1, 2, 3 (testSum) Time elapsed: 0.012 s", elapsedTimeSummary);
+ assertEquals("[0] 1, 2, 3 (testSum) -- Time elapsed: 0.012 s", elapsedTimeSummary);
}
}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
index a7bd1b0ac..0c2a98a50 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
@@ -193,7 +193,7 @@ public class StatelessTestsetInfoReporterTest {
.hasSize(2)
.containsSequence(
"Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.03 s "
- + "<<< FAILURE! - in pkg.MyTest",
+ + "<<< FAILURE! -- in pkg.MyTest",
"pkg.MyTest failed");
verifyNoMoreInteractions(consoleLogger);
}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java
index fd9266e9b..681fa0080 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnit47ConcurrencyIT.java
@@ -51,6 +51,6 @@ public class JUnit47ConcurrencyIT extends SurefireJUnit4IntegrationTestCase {
containsString("Time elapsed: 1."),
containsString("Time elapsed: 1 s"),
containsString("Time elapsed: 0.9")));
- assertThat(result, endsWith(" s - in concurrentjunit47.src.test.java.junit47.BasicTest"));
+ assertThat(result, endsWith(" s -- in concurrentjunit47.src.test.java.junit47.BasicTest"));
}
}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java
index ee4e7fa36..d6513b167 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java
@@ -381,7 +381,7 @@ public class JUnitPlatformEnginesIT extends SurefireJUnit4IntegrationTestCase {
validator
.getSurefireReportsFile("junitplatformenginejupiter.DisplayNameTest.txt", UTF_8)
- .assertContainsText(" - in << ✨ >>");
+ .assertContainsText(" -- in << ✨ >>");
validator
.getSurefireReportsFile("junitplatformenginejupiter.DisplayNameTest-output.txt", UTF_8)
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java
index 898c2d152..9579d721a 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1185DoNotSpawnTestsIT.java
@@ -32,9 +32,9 @@ import static org.hamcrest.Matchers.is;
* Example, UnlistedTest is the problem here because it runs with filtered out methods:
*
* Running pkg.UnlistedTest
- * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec - in pkg.UnlistedTest
+ * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec -- in pkg.UnlistedTest
* Running pkg.RunningTest
- * Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec - in pkg.RunningTest
+ * Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec -- in pkg.RunningTest
*
* Results:
*
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire747MethodParallelWithSuiteCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire747MethodParallelWithSuiteCountIT.java
index 6005dec78..122071331 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire747MethodParallelWithSuiteCountIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire747MethodParallelWithSuiteCountIT.java
@@ -115,7 +115,9 @@ public class Surefire747MethodParallelWithSuiteCountIT extends SurefireJUnit4Int
containsString("Time elapsed: " + delayMax)));
assertThat(
line,
- anyOf(endsWith(" s - in surefire747.SuiteTest1"), endsWith(" s - in surefire747.SuiteTest2")));
+ anyOf(
+ endsWith(" s -- in surefire747.SuiteTest1"),
+ endsWith(" s -- in surefire747.SuiteTest2")));
}
}
}
[maven-surefire] 01/03: [SUREFIRE-2164] Simplify serialization of elapsed time in XML reporter
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch stacked-fixes
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit af2adf0d02665571f36b511f5b12455bea65a3ba
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri May 19 19:18:01 2023 +0200
[SUREFIRE-2164] Simplify serialization of elapsed time in XML reporter
This closes #637
---
.../surefire/report/StatelessXmlReporter.java | 57 ++++++++++++----------
1 file changed, 32 insertions(+), 25 deletions(-)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index 7a9a019d9..62299da4e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -48,42 +48,45 @@ import static org.apache.maven.plugin.surefire.report.ReportEntryType.SKIPPED;
import static org.apache.maven.plugin.surefire.report.ReportEntryType.SUCCESS;
import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
-@SuppressWarnings({"javadoc", "checkstyle:javadoctype"})
// CHECKSTYLE_OFF: LineLength
-/*
+/**
* XML format reporter writing to <code>TEST-<i>reportName</i>[-<i>suffix</i>].xml</code> file like written and read
* by Ant's <a href="http://ant.apache.org/manual/Tasks/junit.html"><code><junit></code></a> and
* <a href="http://ant.apache.org/manual/Tasks/junitreport.html"><code><junitreport></code></a> tasks,
* then supported by many tools like CI servers.
* <br>
- * <pre><?xml version="1.0" encoding="UTF-8"?>
- * <testsuite name="<i>suite name</i>" [group="<i>group</i>"] tests="<i>0</i>" failures="<i>0</i>" errors="<i>0</i>" skipped="<i>0</i>" time="<i>0,###.###</i>">
- * <properties>
- * <property name="<i>name</i>" value="<i>value</i>"/>
+ * <pre><?xml version="1.0" encoding="UTF-8"?>
+ * <testsuite name="<i>suite name</i>" [group="<i>group</i>"] tests="<i>0</i>" failures="<i>0</i>" errors="<i>0</i>" skipped="<i>0</i>" time="<i>{float}</i>">
+ * <properties>
+ * <property name="<i>name</i>" value="<i>value</i>"/>
* [...]
- * </properties>
- * <testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]"/>
- * <testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
- * <<b>error</b> message="<i>message</i>" type="<i>exception class name</i>"><i>stacktrace</i></error>
- * <system-out><i>system out content (present only if not empty)</i></system-out>
- * <system-err><i>system err content (present only if not empty)</i></system-err>
- * </testcase>
- * <testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
- * <<b>failure</b> message="<i>message</i>" type="<i>exception class name</i>"><i>stacktrace</i></failure>
- * <system-out><i>system out content (present only if not empty)</i></system-out>
- * <system-err><i>system err content (present only if not empty)</i></system-err>
- * </testcase>
- * <testcase time="<i>0,###.###</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
- * <<b>skipped</b>/>
- * </testcase>
+ * </properties>
+ * <testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]"/>
+ * <testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
+ * <<b>error</b> message="<i>message</i>" type="<i>exception class name</i>"><i>stacktrace</i></error>
+ * <system-out><i>system out content (present only if not empty)</i></system-out>
+ * <system-err><i>system err content (present only if not empty)</i></system-err>
+ * </testcase>
+ * <testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
+ * <<b>failure</b> message="<i>message</i>" type="<i>exception class name</i>"><i>stacktrace</i></failure>
+ * <system-out><i>system out content (present only if not empty)</i></system-out>
+ * <system-err><i>system err content (present only if not empty)</i></system-err>
+ * </testcase>
+ * <testcase time="<i>{float}</i>" name="<i>test name</i> [classname="<i>class name</i>"] [group="<i>group</i>"]">
+ * <<b>skipped</b>/>
+ * </testcase>
* [...]</pre>
*
* @author Kristian Rosenvold
- * @see <a href="http://wiki.apache.org/ant/Proposals/EnhancedTestReports">Ant's format enhancement proposal</a>
+ * @see <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=115528872">Ant's format enhancement proposal</a>
* (not yet implemented by Ant 1.8.2)
+ * @see <a href="https://github.com/apache/ant/blob/6f68fbdefad521741b37304cfdfc6d8646cf1839/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java">Ant's <code>XMLJUnitResultFormatter</code></a>
*/
-// todo this is no more stateless due to existence of testClassMethodRunHistoryMap since of 2.19.
+@SuppressWarnings({"javadoc", "checkstyle:javadoctype"})
+// TODO this is no more stateless due to existence of testClassMethodRunHistoryMap since of 2.19.
public class StatelessXmlReporter implements StatelessReportEventListener<WrappedReportEntry, TestSetStats> {
+ private static final float ONE_SECOND = 1000.0f;
+
private static final String XML_INDENT = " ";
private static final String XML_NL = "\n";
@@ -387,7 +390,9 @@ public class StatelessXmlReporter implements StatelessReportEventListener<Wrappe
ppw.addAttribute("classname", extraEscapeAttribute(className));
}
- ppw.addAttribute("time", report.elapsedTimeAsString());
+ if (report.getElapsed() != null) {
+ ppw.addAttribute("time", String.valueOf(report.getElapsed() / ONE_SECOND));
+ }
}
private void createTestSuiteElement(XMLWriter ppw, WrappedReportEntry report, TestSetStats testSetStats)
@@ -407,7 +412,9 @@ public class StatelessXmlReporter implements StatelessReportEventListener<Wrappe
ppw.addAttribute("group", report.getGroup());
}
- ppw.addAttribute("time", report.elapsedTimeAsString());
+ if (report.getElapsed() != null) {
+ ppw.addAttribute("time", String.valueOf(report.getElapsed() / ONE_SECOND));
+ }
ppw.addAttribute("tests", String.valueOf(testSetStats.getCompletedCount()));