use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class JUnitTestHeuristicTest method testMatchesJunit4Annotation.
@Test
public void testMatchesJunit4Annotation() {
PsiFile psiFile = workspace.createPsiFile(new WorkspacePath("java/com/google/lib/JavaClass.java"), "package com.google.lib;", "import org.junit.Test;", "import org.junit.runner.RunWith;", "import org.junit.runners.JUnit4;", "@RunWith(JUnit4.class)", "public class JavaClass {", " @Test", " public void testMethod1() {}", " @Test", " public void testMethod2() {}", "}");
File file = new File(psiFile.getVirtualFile().getPath());
TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:AllJUnit4Tests").setKind("java_test").build().toTargetInfo();
assertThat(new JUnitTestHeuristic().matchesSource(getProject(), target, psiFile, file, null)).isTrue();
}
use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class JUnitTestHeuristicTest method testNonJavaFileDoesNotMatch.
@Test
public void testNonJavaFileDoesNotMatch() {
PsiFile psiFile = workspace.createPsiFile(new WorkspacePath("foo/script_test.py"));
File file = new File(psiFile.getVirtualFile().getPath());
TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:unrelatedName").setKind("py_test").build().toTargetInfo();
assertThat(new JUnitTestHeuristic().matchesSource(getProject(), target, psiFile, file, null)).isFalse();
}
use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class JUnitTestHeuristicTest method testIgnoresJunit4AnnotationIfTargetNameDoesNotMatch.
@Test
public void testIgnoresJunit4AnnotationIfTargetNameDoesNotMatch() {
PsiFile psiFile = workspace.createPsiFile(new WorkspacePath("java/com/google/lib/JavaClass.java"), "package com.google.lib;", "import org.junit.Test;", "import org.junit.runner.RunWith;", "import org.junit.runners.JUnit4;", "@RunWith(JUnit4.class)", "public class JavaClass {", " @Test", " public void testMethod1() {}", " @Test", " public void testMethod2() {}", "}");
File file = new File(psiFile.getVirtualFile().getPath());
TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:unrelatedName").setKind("java_test").build().toTargetInfo();
assertThat(new JUnitTestHeuristic().matchesSource(getProject(), target, psiFile, file, null)).isFalse();
}
use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class JUnitTestHeuristicTest method testNullPsiFileDoesNotMatch.
@Test
public void testNullPsiFileDoesNotMatch() {
File file = new File("foo/script_test.py");
TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:unrelatedName").setKind("py_test").build().toTargetInfo();
assertThat(new JUnitTestHeuristic().matchesSource(getProject(), target, null, file, null)).isFalse();
}
use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class JUnitTestHeuristicTest method testJunit4SourceDoesNotMatchJunit3TargetName.
@Test
public void testJunit4SourceDoesNotMatchJunit3TargetName() {
PsiFile psiFile = workspace.createPsiFile(new WorkspacePath("java/com/google/lib/JavaClass.java"), "package com.google.lib;", "import org.junit.Test;", "import org.junit.runner.RunWith;", "import org.junit.runners.JUnit4;", "@RunWith(JUnit4.class)", "public class JavaClass {", " @Test", " public void testMethod1() {}", " @Test", " public void testMethod2() {}", "}");
File file = new File(psiFile.getVirtualFile().getPath());
TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:AllJUnit3Tests").setKind("java_test").build().toTargetInfo();
assertThat(new JUnitTestHeuristic().matchesSource(getProject(), target, psiFile, file, null)).isFalse();
}
Aggregations