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());
}
}
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");
}
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<>());
}
}
}
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");
}
}
}
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());
}
Aggregations