JUnit4: test function annotated with 'test' annotation
#KT-3178 Fixed
This commit is contained in:
@@ -101,7 +101,15 @@ public class KotlinAnnotatedElementsSearcher extends AnnotatedElementsSearcher {
|
||||
@Override
|
||||
public Collection<? extends PsiElement> compute() {
|
||||
if (useScope instanceof GlobalSearchScope) {
|
||||
return JetAnnotationsIndex.getInstance().get(annClass.getName(), annClass.getProject(), (GlobalSearchScope)useScope);
|
||||
Collection<JetAnnotationEntry> annotationEntries =
|
||||
JetAnnotationsIndex.getInstance().get(annClass.getName(), annClass.getProject(), (GlobalSearchScope) useScope);
|
||||
|
||||
// Add annotations 'test' as often used alias when we search Test annotation
|
||||
if (annClass.getName().equals("Test")) {
|
||||
annotationEntries.addAll(JetAnnotationsIndex.getInstance().get(annClass.getName().toLowerCase(), annClass.getProject(), (GlobalSearchScope) useScope));
|
||||
}
|
||||
|
||||
return annotationEntries;
|
||||
}
|
||||
/*
|
||||
TODO getJetAnnotationCandidates works only with global search scope
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import org.junit.Test as test
|
||||
import org.junit.Test
|
||||
|
||||
class MyTestClass {
|
||||
test fun test1() {}
|
||||
|
||||
[Deprecated test] fun test2() {}
|
||||
|
||||
Test fun test3() {}
|
||||
}
|
||||
|
||||
// ANNOTATION: org.junit.Test
|
||||
// SEARCH: PsiMethod:test1, PsiMethod:test2, PsiMethod:test3
|
||||
@@ -63,6 +63,18 @@ public class JUnitMembersSearcherTest extends AbstractSearcherTest {
|
||||
};
|
||||
|
||||
public void testJunit3() throws IOException {
|
||||
doJUnit3test();
|
||||
}
|
||||
|
||||
public void testJunit4() throws IOException {
|
||||
doJUnit4test();
|
||||
}
|
||||
|
||||
public void testJunit4Alias() throws IOException {
|
||||
doJUnit4test();
|
||||
}
|
||||
|
||||
private void doJUnit3test() throws IOException {
|
||||
myFixture.configureByFile(getFileName());
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefix("// CLASS: ", FileUtil.loadFile(new File(getPathToFile())));
|
||||
assertFalse("Specify CLASS directive in test file", directives.isEmpty());
|
||||
@@ -71,7 +83,7 @@ public class JUnitMembersSearcherTest extends AbstractSearcherTest {
|
||||
checkResult(ClassInheritorsSearch.search(psiClass, getProjectScope(), false));
|
||||
}
|
||||
|
||||
public void testJunit4() throws IOException {
|
||||
private void doJUnit4test() throws IOException {
|
||||
myFixture.configureByFile(getFileName());
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefix("// ANNOTATION: ", FileUtil.loadFile(new File(getPathToFile())));
|
||||
assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty());
|
||||
|
||||
Reference in New Issue
Block a user