Lines 10-15
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.internal.junit.ui; |
11 |
package org.eclipse.jdt.internal.junit.ui; |
12 |
|
12 |
|
|
|
13 |
import java.util.ArrayList; |
14 |
import java.util.List; |
13 |
import java.util.regex.Matcher; |
15 |
import java.util.regex.Matcher; |
14 |
import java.util.regex.Pattern; |
16 |
import java.util.regex.Pattern; |
15 |
|
17 |
|
Lines 24-29
import org.eclipse.ui.PlatformUI;
Link Here
|
24 |
|
26 |
|
25 |
import org.eclipse.ui.texteditor.ITextEditor; |
27 |
import org.eclipse.ui.texteditor.ITextEditor; |
26 |
|
28 |
|
|
|
29 |
import org.eclipse.jdt.core.IAnnotation; |
27 |
import org.eclipse.jdt.core.IJavaElement; |
30 |
import org.eclipse.jdt.core.IJavaElement; |
28 |
import org.eclipse.jdt.core.IJavaProject; |
31 |
import org.eclipse.jdt.core.IJavaProject; |
29 |
import org.eclipse.jdt.core.IMethod; |
32 |
import org.eclipse.jdt.core.IMethod; |
Lines 134-139
public class OpenTestAction extends OpenEditorAction {
Link Here
|
134 |
IMethod method= type.getMethod(fMethodName, new String[0]); |
137 |
IMethod method= type.getMethod(fMethodName, new String[0]); |
135 |
if (method != null && method.exists()) |
138 |
if (method != null && method.exists()) |
136 |
return method; |
139 |
return method; |
|
|
140 |
|
141 |
// search just by name, if method not found yet (for custom runner with test methods having parameters) |
142 |
try { |
143 |
List<IMethod> foundMethods = new ArrayList<IMethod>(); |
144 |
for (IMethod method2 : type.getMethods()) { |
145 |
String methodName = method2.getElementName(); |
146 |
IAnnotation methodAnnotation = method2.getAnnotation("Test"); |
147 |
|
148 |
// JUnit3 test method starts with "test" or JUnit4 test method is annotated with "@Test" |
149 |
if (!(methodName.startsWith("test") || (methodAnnotation != null && methodAnnotation.exists()))) |
150 |
continue; |
151 |
|
152 |
if (fMethodName.equals(methodName)) |
153 |
foundMethods.add(method2); |
154 |
} |
155 |
if (foundMethods.isEmpty()) |
156 |
return null; |
157 |
else if (foundMethods.size() > 1) { |
158 |
// TODO ? |
159 |
return null; |
160 |
} else |
161 |
return foundMethods.get(0); |
162 |
} catch (JavaModelException e) { |
163 |
// if type does not exist or if an exception occurs while accessing its resource => ignore (no method found) |
164 |
} |
165 |
|
137 |
return null; |
166 |
return null; |
138 |
} |
167 |
} |
139 |
|
168 |
|
140 |
- |
|
|