Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert workaround for #945, as it causes problems in the JUnit view #1203

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading