Skip to content

Commit

Permalink
Revert workaround for #945, as it causes problems in the JUnit view
Browse files Browse the repository at this point in the history
  • Loading branch information
trancexpress committed Feb 16, 2024
1 parent f995109 commit 645c6ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2023 IBM Corporation and others.
* Copyright (c) 2000, 2017 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,7 +15,6 @@
package org.eclipse.jdt.internal.junit.model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.jdt.junit.model.ITestElement;
Expand Down Expand Up @@ -48,8 +47,7 @@ public String getSuiteTypeName() {

@Override
public ITestElement[] getChildren() {
TestElement[] elements= fChildren.toArray(new TestElement[fChildren.size()]); // copy list to avoid concurrency problems
return Arrays.stream(elements).filter(e -> !isSingleDynamicTest(e)).toArray(ITestElement[]::new);
return fChildren.toArray(new ITestElement[fChildren.size()]);
}

public void addChild(TestElement child) {
Expand Down Expand Up @@ -156,44 +154,4 @@ public String toString() {
return "TestSuite: " + getTestName() + " : " + super.toString() + " (" + fChildren.size() + ")"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}

@Override
public String getTrace() {
TestCaseElement child= getSingleDynamicChild();
if (child != null) {
return child.getTrace();
}
return super.getTrace();
}

private static boolean isSingleDynamicTest(TestElement element) {
if (element instanceof TestCaseElement) {
TestCaseElement testCase = (TestCaseElement) element;
TestSuiteElement suite = testCase.getParent();
if (testCase.isDynamicTest() && suite.fChildren.size() == 1) {
return true;
}
}
return false;
}

/**
* If this test suite is a {@code @TestTemplate} test case with a single child, return that child.
* @return The single dynamic test case child or {@code null} if the suite has no children or multiple or non-dynamid children.
*/
public TestCaseElement getSingleDynamicChild() {
try {
if (fChildren.size() == 1) {
TestElement child= fChildren.get(0);
if (child instanceof TestCaseElement) {
TestCaseElement testCase= (TestCaseElement) child;
if (testCase.isDynamicTest()) {
return testCase;
}
}
}
} catch (IndexOutOfBoundsException e) {
// don't care, children changed concurrently
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,6 @@ private OpenTestAction getOpenTestAction(TestSuiteElement testSuite) {
// a group of parameterized tests
return new OpenTestAction(fTestRunnerPart, (TestCaseElement) children[0], null);
}
if (children.length == 0) {
// check if we have applied the workaround for: https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/945
TestCaseElement child= testSuite.getSingleDynamicChild();
if (child != null) {
// a parameterized test that ran only one test
return new OpenTestAction(fTestRunnerPart, child, null);
}
}

int index= testName.indexOf('(');
// test factory method
Expand Down

0 comments on commit 645c6ed

Please sign in to comment.