mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit: navigate to test 'constructor' for ignored tests (IDEA-159038)
This commit is contained in:
@@ -56,8 +56,7 @@ public class JavaTestLocator implements SMTestLocator {
|
||||
PsiClass aClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), path, null, true, scope);
|
||||
if (aClass != null) {
|
||||
results = ContainerUtil.newSmartList();
|
||||
results.add(paramName != null ? PsiMemberParameterizedLocation.getParameterizedLocation(aClass, paramName)
|
||||
: new PsiLocation<>(project, aClass));
|
||||
results.add(createClassNavigatable(paramName, aClass));
|
||||
}
|
||||
}
|
||||
else if (TEST_PROTOCOL.equals(protocol)) {
|
||||
@@ -67,11 +66,16 @@ public class JavaTestLocator implements SMTestLocator {
|
||||
PsiClass aClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), className, null, true, scope);
|
||||
if (aClass != null) {
|
||||
results = ContainerUtil.newSmartList();
|
||||
PsiMethod[] methods = aClass.findMethodsByName(methodName.trim(), true);
|
||||
if (methods.length > 0) {
|
||||
for (PsiMethod method : methods) {
|
||||
results.add(paramName != null ? new PsiMemberParameterizedLocation(project, method, aClass, paramName)
|
||||
: MethodLocation.elementInClass(method, aClass));
|
||||
if (methodName.trim().equals(aClass.getName())) {
|
||||
results.add(createClassNavigatable(paramName, aClass));
|
||||
}
|
||||
else {
|
||||
PsiMethod[] methods = aClass.findMethodsByName(methodName.trim(), true);
|
||||
if (methods.length > 0) {
|
||||
for (PsiMethod method : methods) {
|
||||
results.add(paramName != null ? new PsiMemberParameterizedLocation(project, method, aClass, paramName)
|
||||
: MethodLocation.elementInClass(method, aClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,4 +84,9 @@ public class JavaTestLocator implements SMTestLocator {
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private Location createClassNavigatable(String paramName, @NotNull PsiClass aClass) {
|
||||
return paramName != null ? PsiMemberParameterizedLocation.getParameterizedLocation(aClass, paramName)
|
||||
: new PsiLocation<>(aClass.getProject(), aClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,4 +150,20 @@ public class JUnitRerunFailedTestsTest extends LightCodeInsightFixtureTestCase
|
||||
String name = ((PsiMethod)element).getName();
|
||||
assertEquals("testFoo", name);
|
||||
}
|
||||
|
||||
public void testLocatorForIgnoredClass() throws Exception {
|
||||
PsiClass aClass = myFixture.addClass("@org.junit.Ignore" +
|
||||
"public class TestClass {\n" +
|
||||
" @org.junit.Test" +
|
||||
" public void testFoo() throws Exception {}\n" +
|
||||
"}");
|
||||
final SMTestProxy testProxy = new SMTestProxy("TestClass", false, "java:test://TestClass.TestClass");
|
||||
final Project project = getProject();
|
||||
final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project);
|
||||
testProxy.setLocator(JavaTestLocator.INSTANCE);
|
||||
Location location = testProxy.getLocation(project, searchScope);
|
||||
assertNotNull(location);
|
||||
PsiElement element = location.getPsiElement();
|
||||
assertEquals(aClass, element);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user