[java-tests] IDEA-169282 IJ-CR-152163 Unit test elapsed time should be a wall time from start to end for Gradle, TestNG, JUnit

- fix IDEA-365756, terminated case

GitOrigin-RevId: 6c2064a5785b97a85e41ab5a9e5b8dbc3dbce80e
This commit is contained in:
Mikhail Pyltsin
2025-01-16 14:21:49 +00:00
committed by intellij-monorepo-bot
parent b99ef38216
commit 2afb61710c
3 changed files with 19 additions and 2 deletions
@@ -132,7 +132,8 @@ public class JavaSMTRunnerTestTreeView extends SMTRunnerTestTreeView implements
SMTestProxy test = getSelectedTest(location);
if (test == null || test.isLeaf() || test.getDurationStrategy() != TestDurationStrategy.AUTOMATIC ||
test.getEndTime() == null || test.getStartTime() == null) {
test.getEndTime() == null || test.getStartTime() == null ||
test.getEndTime() <= test.getStartTime()) {
return null;
}
@@ -883,7 +883,7 @@ public class SMTestProxy extends AbstractTestProxy implements Navigatable {
if (myState.isFinal()) {
return;
}
if (myEndTime != null) {
if (myEndTime == null) {
myEndTime = endTime;
}
myState = TerminatedState.INSTANCE;
@@ -1154,6 +1154,22 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
assertTrue(root.getEndTime() - root.getStartTime() != root.getDuration());
}
public void testDisplayOwnTimeTerminated() {
SMTestProxy root = createSuiteProxy("root");
SMTestProxy child1 = createTestProxy("child1", root);
SMTestProxy child2 = createTestProxy("child12", root);
root.setStarted();
child1.setStarted();
root.setTerminated();
assertNotNull(root.getEndTime());
assertNotNull(child1.getEndTime());
assertNotNull(child2.getEndTime());
}
private static void assertDisplayTimeEqualsToSumOfChildren(@NotNull SMTestProxy node) {
List<? extends SMTestProxy> children = node.collectChildren(new Filter<>() {
@Override