Search in sources :

Example 16 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class DetectClassesToRunTest method testDependsOnGroupDontIncludeForeignClass.

@Test
public void testDependsOnGroupDontIncludeForeignClass() throws Exception {
    final PsiClass aClass = myFixture.addClass("package a; public class ATest {" + "  @org.testng.annotations.Test(groups = { \"g1\" })\n" + "  public void testTwo(){}\n " + "  @org.testng.annotations.Test(dependsOnGroups = {\"g1\" })\n" + "  public void testOne(){}\n" + "}");
    myFixture.addClass("package a; public class ForeignTest {" + "  @org.testng.annotations.Test(groups = { \"g1\" })\n" + "  public void testForth(){}\n " + "}");
    doTestClassConfiguration(aClass);
}
Also used : PsiClass(com.intellij.psi.PsiClass) Test(org.testng.annotations.Test)

Example 17 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class DetectClassesToRunTest method testOneMethodWhenAnnotationIsOnBaseClassOnly.

@Test
public void testOneMethodWhenAnnotationIsOnBaseClassOnly() throws Exception {
    myFixture.addClass("package a; @org.testng.annotations.Test public class BaseClass {}");
    final PsiClass aClass = myFixture.addClass("package a; public class ATest extends BaseClass {" + "  public void testOne(){}\n" + "}");
    doTestMethodConfiguration(aClass, aClass.getMethods());
}
Also used : PsiClass(com.intellij.psi.PsiClass) Test(org.testng.annotations.Test)

Example 18 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class DetectClassesToRunTest method testRerunFailedTestWithDependency.

public void testRerunFailedTestWithDependency() throws Exception {
    final PsiClass aClass = myFixture.addClass("package a; public class ATest {" + "  @org.testng.annotations.Test()\n" + "  public void testTwo(){}\n " + "  @org.testng.annotations.Test(dependsOnMethods = \"testTwo\")\n" + //parameterized
    "  public void testOne(String s){}\n" + "}");
    final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<>();
    classes.put(aClass, new HashMap<>());
    final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject());
    final SMTestProxy testProxy = new SMTestProxy("testOne", false, "java:test://a.ATest.testOne[a]");
    testProxy.setLocator(new JavaTestLocator());
    RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy);
    assertEquals(1, classes.size());
    final Map<PsiMethod, List<String>> params = classes.get(aClass);
    assertContainsElements(params.keySet(), aClass.getMethods());
    final List<String> paramsToRerun = params.get(aClass.findMethodsByName("testOne", false)[0]);
    assertEquals(1, paramsToRerun.size());
    assertContainsElements(paramsToRerun, "a");
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) LinkedHashMap(java.util.LinkedHashMap) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) List(java.util.List) JavaTestLocator(com.intellij.execution.testframework.JavaTestLocator) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 19 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class GroupBrowser method showDialog.

@Nullable
@Override
protected String showDialog() {
    TestClassFilter filter;
    Module module = editor.getModuleSelector().getModule();
    if (module == null) {
        filter = new TestClassFilter(GlobalSearchScope.projectScope(getProject()), getProject(), false);
    } else {
        filter = new TestClassFilter(GlobalSearchScope.moduleScope(module), getProject(), false);
    }
    PsiClass[] classes = TestNGUtil.getAllTestClasses(filter, true);
    if (classes == null || classes.length == 0) {
        Messages.showMessageDialog(getField(), "No tests found in project", "Cannot Browse Groups", Messages.getInformationIcon());
        return null;
    } else {
        return GroupList.showDialog(classes, getField());
    }
}
Also used : PsiClass(com.intellij.psi.PsiClass) Module(com.intellij.openapi.module.Module) TestClassFilter(com.theoryinpractice.testng.model.TestClassFilter) Nullable(org.jetbrains.annotations.Nullable)

Example 20 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class TestClassBrowser method showDialog.

@Override
protected String showDialog() {
    ClassFilter.ClassFilterWithScope filter;
    try {
        filter = getFilter();
    } catch (MessageInfoException e) {
        MessagesEx.MessageInfo message = e.getMessageInfo();
        message.showNow();
        return null;
    }
    TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()).createWithInnerClassesScopeChooser("Choose Test Class", filter.getScope(), filter, null);
    init(chooser);
    chooser.showDialog();
    PsiClass psiclass = chooser.getSelected();
    if (psiclass == null) {
        return null;
    } else {
        onClassChoosen(psiclass);
        return psiclass.getQualifiedName();
    }
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) ClassFilter(com.intellij.ide.util.ClassFilter) TestClassFilter(com.theoryinpractice.testng.model.TestClassFilter) PsiClass(com.intellij.psi.PsiClass) MessageInfoException(com.theoryinpractice.testng.MessageInfoException)

Aggregations

PsiClass (com.intellij.psi.PsiClass)594 PsiElement (com.intellij.psi.PsiElement)113 PsiMethod (com.intellij.psi.PsiMethod)97 Nullable (org.jetbrains.annotations.Nullable)75 NotNull (org.jetbrains.annotations.NotNull)60 Project (com.intellij.openapi.project.Project)59 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)57 Module (com.intellij.openapi.module.Module)55 PsiFile (com.intellij.psi.PsiFile)49 VirtualFile (com.intellij.openapi.vfs.VirtualFile)47 ArrayList (java.util.ArrayList)37 PsiField (com.intellij.psi.PsiField)36 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)25 Location (com.intellij.execution.Location)20 File (java.io.File)16 HashSet (java.util.HashSet)16 PsiClassType (com.intellij.psi.PsiClassType)15 PsiPackage (com.intellij.psi.PsiPackage)15 List (java.util.List)15 PsiType (com.intellij.psi.PsiType)13