From ae516690f79ebc25daee1bb0f0a45a77355e01a6 Mon Sep 17 00:00:00 2001 From: Georgii Ustinov Date: Thu, 1 Aug 2024 15:05:15 +0300 Subject: [PATCH] [Java. Tests] Make SMTestProxyTest#assertDisplayTimeEqualsToSumOfChildren non-flaky IDEA-169405 GitOrigin-RevId: 0a9d04d864e7b58f2784e65307edaf96fb214047 --- .../testframework/sm/runner/SMTestProxyTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java index 4b8640ab30b3..ec62922b4d27 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java @@ -1075,6 +1075,8 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase { secondSubSuite.setStarted(); secondSubSuiteChild.setStarted(); root.setTerminated(); + firstSubSuiteChild.setDuration(10L); + secondSubSuiteChild.setDuration(5L); assertDisplayTimeEqualsToSumOfChildren(firstSubSuite); assertDisplayTimeEqualsToSumOfChildren(secondSubSuite); @@ -1089,6 +1091,7 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase { root.setStarted(); firstChild.setStarted(); root.setTerminated(); + firstChild.setDuration(5L); assertNotNull(secondChild.getDuration()); assertEquals(0L, secondChild.getDuration().longValue()); @@ -1106,10 +1109,12 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase { passedChild.setStarted(); passedChild.setFinished(); + passedChild.setDuration(10L); Long passedChildDuration = passedChild.getDuration(); failedChild.setStarted(); failedChild.setTestFailed("message", "stacktrace", true); + failedChild.setDuration(5L); Long failedChildDuration = failedChild.getDuration(); ignoredChild.setStarted(); @@ -1127,7 +1132,12 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase { } private static void assertDisplayTimeEqualsToSumOfChildren(@NotNull SMTestProxy node) { - List children = node.collectChildren(); + List children = node.collectChildren(new Filter<>() { + @Override + public boolean shouldAccept(SMTestProxy test) { + return test.isLeaf(); + } + }); assertTrue(ContainerUtil.all(children, child -> !child.wasTerminated() || child.getDuration() != null)); Long totalTime = ContainerUtil.reduce(ContainerUtil.map(children, child -> child.getDuration() == null ? 0 : child.getDuration()), 0L, (a, b) -> a + b);