From 9101885aa4e4ccbd763fecaa3226e51e0adce4c7 Mon Sep 17 00:00:00 2001 From: jonmv Date: Tue, 7 Jun 2022 09:51:04 +0200 Subject: Use Display Name over some.class.or.method.ID --- .../com/yahoo/vespa/testrunner/TestReport.java | 22 ++++++++++++---------- .../src/test/resources/report.json | 14 +++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'vespa-osgi-testrunner') diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java index 016b5588e1c..9aae329d7fb 100644 --- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java +++ b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestReport.java @@ -45,7 +45,7 @@ public class TestReport { } TestReport(Clock clock, Suite suite) { - this(clock, suite, new ContainerNode(null, toString(suite), clock.instant())); + this(clock, suite, new ContainerNode(null, null, toString(suite), clock.instant())); } static TestReport createFailed(Clock clock, Suite suite, Throwable thrown) { @@ -60,7 +60,7 @@ public class TestReport { private void verifyStructure(NamedNode node, UniqueId id) { Deque path = new ArrayDeque<>(); while (node != root) { - path.push(node.name); + path.push(node.id); node = node.parent; } Deque segments = new ArrayDeque<>(); @@ -79,8 +79,8 @@ public class TestReport { void start(TestIdentifier id) { synchronized (monitor) { - NamedNode child = id.isTest() ? new TestNode(current, id.getUniqueIdObject().getLastSegment().getValue(), clock.instant()) - : new ContainerNode(current, id.getUniqueIdObject().getLastSegment().getValue(), clock.instant()); + NamedNode child = id.isTest() ? new TestNode(current, id.getUniqueIdObject().getLastSegment().getValue(), id.getDisplayName(), clock.instant()) + : new ContainerNode(current, id.getUniqueIdObject().getLastSegment().getValue(), id.getDisplayName(), clock.instant()); verifyStructure(child, id.getUniqueIdObject()); current.children.add(child); current = child; @@ -154,7 +154,7 @@ public class TestReport { if (root.start().isAfter(other.root.start())) throw new IllegalArgumentException("appended test report cannot have started before the one appended to"); - ContainerNode newRoot = new ContainerNode(null, root.name(), root.start()); + ContainerNode newRoot = new ContainerNode(null, null, root.name(), root.start()); newRoot.children.addAll(root.children); newRoot.children.addAll(other.root.children); TestReport merged = new TestReport(clock, suite, newRoot); @@ -203,13 +203,15 @@ public class TestReport { static abstract class NamedNode extends Node { + private final String id; private final String name; private final Instant start; private Status status; private Instant end; - NamedNode(NamedNode parent, String name, Instant now) { + NamedNode(NamedNode parent, String id, String name, Instant now) { super(parent); + this.id = id; this.name = name; this.start = now; } @@ -236,16 +238,16 @@ public class TestReport { public static class ContainerNode extends NamedNode { - ContainerNode(NamedNode parent, String name, Instant now) { - super(parent, name, now); + ContainerNode(NamedNode parent, String name, String display, Instant now) { + super(parent, name, display, now); } } public static class TestNode extends NamedNode { - TestNode(NamedNode parent, String name, Instant now) { - super(parent, name, now); + TestNode(NamedNode parent, String name, String display, Instant now) { + super(parent, name, display, now); } @Override diff --git a/vespa-osgi-testrunner/src/test/resources/report.json b/vespa-osgi-testrunner/src/test/resources/report.json index 0d2e70a6c4d..16c491ef61c 100644 --- a/vespa-osgi-testrunner/src/test/resources/report.json +++ b/vespa-osgi-testrunner/src/test/resources/report.json @@ -8,14 +8,14 @@ "children": [ { "type": "container", - "name": "junit-jupiter", + "name": "JUnit Jupiter", "status": "error", "start": 0, "end": 0, "children": [ { "type": "container", - "name": "com.yahoo.vespa.test.samples.SampleTest", + "name": "SampleTest", "status": "error", "start": 0, "end": 0, @@ -101,7 +101,7 @@ }, { "type": "test", - "name": "inconclusive(org.junit.jupiter.api.TestReporter)", + "name": "inconclusive(TestReporter)", "status": "inconclusive", "start": 0, "end": 0, @@ -189,7 +189,7 @@ }, { "type": "test", - "name": "#1", + "name": "second", "status": "successful", "start": 0, "end": 0, @@ -208,7 +208,7 @@ }, { "type": "test", - "name": "#2", + "name": "third", "status": "failed", "start": 0, "end": 0, @@ -283,12 +283,12 @@ "exception": "org.opentest4j.AssertionFailedError: baz ==> expected: but was: \n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)\n\tat org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)\n\tat org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)\n\tat org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1152)\n\tat com.yahoo.vespa.test.samples.SampleTest.failing(SampleTest.java:81)\n" }, { - "testName": "inconclusive(org.junit.jupiter.api.TestReporter)", + "testName": "inconclusive(TestReporter)", "testError": "the cat is both dead _and_ alive", "exception": "ai.vespa.hosted.cd.InconclusiveTestException: the cat is both dead _and_ alive\n\tat com.yahoo.vespa.test.samples.SampleTest.inconclusive(SampleTest.java:93)\n" }, { - "testName": "#2", + "testName": "third", "testError": "no charm", "exception": "org.opentest4j.AssertionFailedError: no charm\n\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:39)\n\tat org.junit.jupiter.api.Assertions.fail(Assertions.java:134)\n\tat com.yahoo.vespa.test.samples.SampleTest$Inner.lambda$others$1(SampleTest.java:105)\n" } -- cgit v1.2.3