diff --git a/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/Configuration.java b/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/Configuration.java index fd848fa..481a52f 100644 --- a/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/Configuration.java +++ b/src/library/src/main/java/com/github/sbt/junit/jupiter/internal/Configuration.java @@ -317,7 +317,11 @@ 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 getPath(TestPlan testPlan, TestIdentifier identifier) { @@ -325,7 +329,10 @@ private List getPath(TestPlan testPlan, TestIdentifier identifie List 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); @@ -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()) {