Search in sources :

Example 1 with SourceScope

use of com.intellij.execution.testframework.SourceScope in project intellij-community by JetBrains.

the class TestNGConsoleProperties method initScope.

@NotNull
@Override
protected GlobalSearchScope initScope() {
    final TestNGConfiguration configuration = getConfiguration();
    final String testObject = configuration.getPersistantData().TEST_OBJECT;
    if (TestType.CLASS.getType().equals(testObject) || TestType.METHOD.getType().equals(testObject)) {
        return super.initScope();
    } else {
        final SourceScope sourceScope = configuration.getPersistantData().getScope().getSourceScope(configuration);
        return sourceScope != null ? sourceScope.getGlobalSearchScope() : GlobalSearchScope.allScope(getProject());
    }
}
Also used : SourceScope(com.intellij.execution.testframework.SourceScope) TestNGConfiguration(com.theoryinpractice.testng.configuration.TestNGConfiguration) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with SourceScope

use of com.intellij.execution.testframework.SourceScope in project intellij-community by JetBrains.

the class TestNGTestClass method checkConfiguration.

@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    final TestData data = myConfig.getPersistantData();
    final SourceScope scope = data.getScope().getSourceScope(myConfig);
    if (scope == null) {
        throw new RuntimeConfigurationException("Invalid scope specified");
    }
    final PsiManager manager = PsiManager.getInstance(myConfig.getProject());
    final PsiClass psiClass = ClassUtil.findPsiClass(manager, data.getMainClassName(), null, true, scope.getGlobalSearchScope());
    if (psiClass == null)
        throw new RuntimeConfigurationException("Class '" + data.getMainClassName() + "' not found");
}
Also used : SourceScope(com.intellij.execution.testframework.SourceScope) RuntimeConfigurationException(com.intellij.execution.configurations.RuntimeConfigurationException)

Example 3 with SourceScope

use of com.intellij.execution.testframework.SourceScope in project intellij-community by JetBrains.

the class TestNGTestGroup method fillTestObjects.

@Override
public void fillTestObjects(Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException {
    final TestData data = myConfig.getPersistantData();
    //for a group, we include all classes
    final SourceScope sourceScope = data.getScope().getSourceScope(myConfig);
    final TestClassFilter classFilter = new TestClassFilter(sourceScope != null ? sourceScope.getGlobalSearchScope() : GlobalSearchScope.allScope(myConfig.getProject()), myConfig.getProject(), true, true);
    PsiClass[] testClasses = TestNGUtil.getAllTestClasses(classFilter, false);
    if (testClasses != null) {
        for (PsiClass c : testClasses) {
            classes.put(c, new LinkedHashMap<>());
        }
    }
}
Also used : SourceScope(com.intellij.execution.testframework.SourceScope) PsiClass(com.intellij.psi.PsiClass)

Example 4 with SourceScope

use of com.intellij.execution.testframework.SourceScope in project intellij-community by JetBrains.

the class TestNGTestMethod method checkConfiguration.

@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    final TestData data = myConfig.getPersistantData();
    final SourceScope scope = data.getScope().getSourceScope(myConfig);
    if (scope == null) {
        throw new RuntimeConfigurationException("Invalid scope specified");
    }
    PsiClass psiClass = JavaPsiFacade.getInstance(myConfig.getProject()).findClass(data.getMainClassName(), scope.getGlobalSearchScope());
    if (psiClass == null)
        throw new RuntimeConfigurationException("Class '" + data.getMainClassName() + "' not found");
    PsiMethod[] methods = psiClass.findMethodsByName(data.getMethodName(), true);
    if (methods.length == 0) {
        throw new RuntimeConfigurationException("Method '" + data.getMethodName() + "' not found");
    }
    for (PsiMethod method : methods) {
        if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
            throw new RuntimeConfigurationException("Non public method '" + data.getMethodName() + "'specified");
        }
    }
}
Also used : SourceScope(com.intellij.execution.testframework.SourceScope) RuntimeConfigurationException(com.intellij.execution.configurations.RuntimeConfigurationException)

Example 5 with SourceScope

use of com.intellij.execution.testframework.SourceScope in project intellij-community by JetBrains.

the class TestNGTestObject method getSearchScope.

@NotNull
protected GlobalSearchScope getSearchScope() {
    final TestData data = myConfig.getPersistantData();
    final Module module = myConfig.getConfigurationModule().getModule();
    if (data.TEST_OBJECT.equals(TestType.PACKAGE.getType())) {
        SourceScope scope = myConfig.getPersistantData().getScope().getSourceScope(myConfig);
        if (scope != null) {
            return scope.getGlobalSearchScope();
        }
    } else if (module != null) {
        return GlobalSearchScope.moduleWithDependenciesScope(module);
    }
    return GlobalSearchScope.projectScope(myConfig.getProject());
}
Also used : SourceScope(com.intellij.execution.testframework.SourceScope) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SourceScope (com.intellij.execution.testframework.SourceScope)13 Module (com.intellij.openapi.module.Module)3 Project (com.intellij.openapi.project.Project)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 CantRunException (com.intellij.execution.CantRunException)2 JavaParameters (com.intellij.execution.configurations.JavaParameters)2 RuntimeConfigurationException (com.intellij.execution.configurations.RuntimeConfigurationException)2 PsiClass (com.intellij.psi.PsiClass)2 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2 JUnitConfiguration (com.intellij.execution.junit.JUnitConfiguration)1 SearchForTestsTask (com.intellij.execution.testframework.SearchForTestsTask)1 TestSearchScope (com.intellij.execution.testframework.TestSearchScope)1 JUnit5IdeaTestRunner (com.intellij.junit5.JUnit5IdeaTestRunner)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PathsList (com.intellij.util.PathsList)1 TestNGConfiguration (com.theoryinpractice.testng.configuration.TestNGConfiguration)1 THashSet (gnu.trove.THashSet)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1