use of com.intellij.execution.junit2.PsiMemberParameterizedLocation in project intellij by bazelbuild.
the class BlazeJUnitTestFilterFlagsIntegrationTest method testMultipleClassesWithParameterizedMethods.
@Test
public void testMultipleClassesWithParameterizedMethods() {
PsiFile javaFile1 = workspace.createPsiFile(new WorkspacePath("java/com/google/lib/JavaClass1.java"), "package com.google.lib;", "import org.junit.Test;", "import org.junit.runner.RunWith;", "import org.junit.runners.JUnit4;", "@RunWith(JUnit4.class)", "public class JavaClass1 {", " @Test", " public void testMethod1() {}", " @Test", " public void testMethod2() {}", "}");
PsiFile javaFile2 = workspace.createPsiFile(new WorkspacePath("java/com/google/lib/JavaClass2.java"), "package com.google.lib;", "import org.junit.Test;", "import org.junit.runner.RunWith;", "import org.junit.runners.JUnit4;", "@RunWith(JUnit4.class)", "public class JavaClass2 {", " @Test", " public void testMethod() {}", "}");
PsiClass javaClass1 = ((PsiClassOwner) javaFile1).getClasses()[0];
PsiMethod class1Method1 = javaClass1.findMethodsByName("testMethod1", false)[0];
Location<?> class1Location1 = new PsiMemberParameterizedLocation(getProject(), class1Method1, javaClass1, "[param]");
PsiMethod class1Method2 = javaClass1.findMethodsByName("testMethod2", false)[0];
Location<?> class1Location2 = new PsiMemberParameterizedLocation(getProject(), class1Method2, javaClass1, "[3]");
PsiClass javaClass2 = ((PsiClassOwner) javaFile2).getClasses()[0];
PsiMethod class2Method = javaClass2.findMethodsByName("testMethod", false)[0];
assertThat(BlazeJUnitTestFilterFlags.testFilterForClassesAndMethods(ImmutableMap.of(javaClass1, ImmutableList.of(class1Location1, class1Location2), javaClass2, ImmutableList.of(new PsiLocation<>(class2Method))))).isEqualTo(Joiner.on('|').join("com.google.lib.JavaClass1#(testMethod1\\[param\\]|testMethod2\\[3\\])$", "com.google.lib.JavaClass2#testMethod$"));
}
use of com.intellij.execution.junit2.PsiMemberParameterizedLocation in project intellij by bazelbuild.
the class BlazeJUnitTestFilterFlagsIntegrationTest method testParameterizedMethods.
@Test
public void testParameterizedMethods() {
PsiFile javaFile = 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() {}", "}");
PsiClass javaClass = ((PsiClassOwner) javaFile).getClasses()[0];
PsiMethod method1 = javaClass.findMethodsByName("testMethod1", false)[0];
Location<?> location1 = new PsiMemberParameterizedLocation(getProject(), method1, javaClass, "[param]");
PsiMethod method2 = javaClass.findMethodsByName("testMethod2", false)[0];
Location<?> location2 = new PsiMemberParameterizedLocation(getProject(), method2, javaClass, "[3]");
assertThat(BlazeJUnitTestFilterFlags.testFilterForClassesAndMethods(ImmutableMap.of(javaClass, ImmutableList.of(location1, location2)))).isEqualTo("com.google.lib.JavaClass#(testMethod1\\[param\\]|testMethod2\\[3\\])$");
}
Aggregations