Skip to content

Handle duplicate test names in report #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.junit.platform.launcher.TestPlan;
Expand Down Expand Up @@ -73,8 +75,15 @@ public void toXml(XMLStreamWriter xml, TestData suite, Collection<TestData> test
xml.writeAttribute("package", "");
xml.writeEmptyElement("properties");

// JUnitParams generates report names based on parameter values rather than parameter types,
// which can result in duplicate test names in the XML output. This situation arises when
// two test methods have identical names but differ in parameter types; however, their
// string representations may be the same (e.g., Integer 1 and Long 1).
Set<String> reportedTests = new HashSet<>();
for (TestData testCase : tests) {
testRenderer.toXml(xml, testCase);
if (reportedTests.add(testCase.getId().getLegacyReportingName())) {
testRenderer.toXml(xml, testCase);
}
}

writeTextElement(xml, "system-out", suite.getStdOut());
Expand Down
Loading