Search in sources :

Example 11 with PsiMemberParameterizedLocation

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$"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) PsiFile(com.intellij.psi.PsiFile) PsiMemberParameterizedLocation(com.intellij.execution.junit2.PsiMemberParameterizedLocation) Test(org.junit.Test)

Example 12 with PsiMemberParameterizedLocation

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\\])$");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) PsiFile(com.intellij.psi.PsiFile) PsiMemberParameterizedLocation(com.intellij.execution.junit2.PsiMemberParameterizedLocation) Test(org.junit.Test)

Aggregations

PsiMemberParameterizedLocation (com.intellij.execution.junit2.PsiMemberParameterizedLocation)12 Location (com.intellij.execution.Location)8 MethodLocation (com.intellij.execution.junit2.info.MethodLocation)6 PsiClass (com.intellij.psi.PsiClass)6 PsiMethod (com.intellij.psi.PsiMethod)6 PsiElement (com.intellij.psi.PsiElement)4 Module (com.intellij.openapi.module.Module)3 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)2 PsiFile (com.intellij.psi.PsiFile)2 LinkedHashSet (java.util.LinkedHashSet)2 Test (org.junit.Test)2 PsiLocation (com.intellij.execution.PsiLocation)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)1 JUnitConfiguration (com.intellij.execution.junit.JUnitConfiguration)1 PatternConfigurationProducer (com.intellij.execution.junit.PatternConfigurationProducer)1 TestObject (com.intellij.execution.junit.TestObject)1 JavaTestLocator (com.intellij.execution.testframework.JavaTestLocator)1 SMTestProxy (com.intellij.execution.testframework.sm.runner.SMTestProxy)1