use of com.theoryinpractice.testng.configuration.TestNGConfiguration 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.theoryinpractice.testng.configuration.TestNGConfiguration in project intellij-community by JetBrains.
the class TestClassBrowser method getFilter.
public ClassFilter.ClassFilterWithScope getFilter() throws MessageInfoException {
TestNGConfiguration config = new TestNGConfiguration("<no-name>", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
editor.applyEditorTo(config);
GlobalSearchScope scope = getSearchScope(config.getModules());
if (scope == null) {
scope = GlobalSearchScope.allScope(getProject());
}
return new TestClassFilter(scope, getProject(), false);
}
use of com.theoryinpractice.testng.configuration.TestNGConfiguration in project intellij-community by JetBrains.
the class RerunFailedTestsAction method getRunProfile.
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
final TestNGConfiguration configuration = (TestNGConfiguration) myConsoleProperties.getConfiguration();
final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
return new MyRunProfile(configuration) {
@Override
@NotNull
public Module[] getModules() {
return configuration.getModules();
}
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) {
return new TestNGRunnableState(env, configuration) {
@Override
public SearchingForTestsTask createSearchingForTestsTask() {
return new SearchingForTestsTask(myServerSocket, getConfiguration(), myTempFile) {
@Override
protected void fillTestObjects(final Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException {
final HashMap<PsiClass, Map<PsiMethod, List<String>>> fullClassList = ContainerUtil.newHashMap();
super.fillTestObjects(fullClassList);
for (final PsiClass aClass : fullClassList.keySet()) {
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return TestNGUtil.hasTest(aClass);
}
})) {
classes.put(aClass, fullClassList.get(aClass));
}
}
final GlobalSearchScope scope = getConfiguration().getConfigurationModule().getSearchScope();
final Project project = getConfiguration().getProject();
for (final AbstractTestProxy proxy : failedTests) {
ApplicationManager.getApplication().runReadAction(() -> includeFailedTestWithDependencies(classes, scope, project, proxy));
}
}
};
}
};
}
};
}
use of com.theoryinpractice.testng.configuration.TestNGConfiguration in project kotlin by JetBrains.
the class KotlinTestNgConfigurationProducer method onFirstRun.
@Override
public void onFirstRun(ConfigurationFromContext configuration, ConfigurationContext context, Runnable startRunnable) {
KtNamedDeclaration declarationToRun = getDeclarationToRun(configuration.getSourceElement());
final PsiNamedElement lightElement = CollectionsKt.firstOrNull(LightClassUtilsKt.toLightElements(declarationToRun));
// Copied from TestNGInClassConfigurationProducer.onFirstRun()
if (lightElement instanceof PsiMethod || lightElement instanceof PsiClass) {
PsiMethod psiMethod;
PsiClass containingClass;
if (lightElement instanceof PsiMethod) {
psiMethod = (PsiMethod) lightElement;
containingClass = psiMethod.getContainingClass();
} else {
psiMethod = null;
containingClass = (PsiClass) lightElement;
}
InheritorChooser inheritorChooser = new InheritorChooser() {
@Override
protected void runForClasses(List<PsiClass> classes, PsiMethod method, ConfigurationContext context, Runnable performRunnable) {
((TestNGConfiguration) context.getConfiguration().getConfiguration()).bePatternConfiguration(classes, method);
super.runForClasses(classes, method, context, performRunnable);
}
@Override
protected void runForClass(PsiClass aClass, PsiMethod psiMethod, ConfigurationContext context, Runnable performRunnable) {
if (lightElement instanceof PsiMethod) {
Project project = psiMethod.getProject();
MethodLocation methodLocation = new MethodLocation(project, psiMethod, PsiLocation.fromPsiElement(aClass));
((TestNGConfiguration) context.getConfiguration().getConfiguration()).setMethodConfiguration(methodLocation);
} else {
((TestNGConfiguration) context.getConfiguration().getConfiguration()).setClassConfiguration(aClass);
}
super.runForClass(aClass, psiMethod, context, performRunnable);
}
};
if (inheritorChooser.runMethodInAbstractClass(context, startRunnable, psiMethod, containingClass, new Condition<PsiClass>() {
@Override
public boolean value(PsiClass aClass) {
return aClass.hasModifierProperty(PsiModifier.ABSTRACT) && TestNGUtil.hasTest(aClass);
}
}))
return;
}
super.onFirstRun(configuration, context, startRunnable);
}
Aggregations