Skip to content
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

Fix handling for unknown JUnit segment types #128

Merged
merged 7 commits into from
Dec 2, 2024
Merged
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 @@ -317,15 +317,22 @@ public String format() {
.reduce((first, last) -> last)
.orElse(null);

return path.stream().map(this::toName).filter(Objects::nonNull).collect(Collectors.joining());
return path.stream()
.map(this::toName)
.filter(Objects::nonNull)
.collect(Collectors.joining())
.trim();
}

private List<TestIdentifier> getPath(TestPlan testPlan, TestIdentifier identifier) {

List<TestIdentifier> result = new ArrayList<>();

do {
if (identifier.getSource().isPresent()) {
// If there is only one segment, do not filter it out even
// if the source is not present, since we need to show something
boolean isOnlySegment = (result.isEmpty());
if (identifier.getSource().isPresent() || isOnlySegment) {
result.add(identifier);
}
identifier = testPlan.getParent(identifier).orElse(null);
Expand Down Expand Up @@ -385,9 +392,12 @@ private String toName(TestIdentifier identifier, Segment segment) {
case "test-template-invocation":
name = colorTheme.container().format(":" + segment.getValue());
break;
default:
case "suite": // Don't show junit5 suite as part of name
name = null;
break;
default:
name = " " + segment.getValue();
break;
}

if (options.isTypesEnabled()) {
Expand Down