use of com.intellij.execution.testframework.AbstractTestProxy in project intellij-community by JetBrains.
the class SMTRunnerUIActionsHandler method onTestingFinished.
public void onTestingFinished(final TestResultsViewer sender) {
// select first defect at the end (my be TRACK_RUNNING_TEST was enabled and affects on the fly selection)
final SMTestProxy testsRootNode = sender.getTestsRootNode();
if (TestConsoleProperties.SELECT_FIRST_DEFECT.value(myConsoleProperties)) {
final AbstractTestProxy firstDefect;
// defects priority:
// ERROR -> FAILURE -> GENERAL DEFECTIVE NODE
final List<SMTestProxy> allTests = testsRootNode.getAllTests();
final AbstractTestProxy firstError = ProxyFilters.ERROR_LEAF.detectIn(allTests);
if (firstError != null) {
firstDefect = firstError;
} else {
final AbstractTestProxy firstFailure = ProxyFilters.FAILURE_LEAF.detectIn(allTests);
if (firstFailure != null) {
firstDefect = firstFailure;
} else {
firstDefect = null;
}
}
// select if detected
if (firstDefect != null) {
sender.selectAndNotify(firstDefect);
}
}
}
use of com.intellij.execution.testframework.AbstractTestProxy in project intellij-community by JetBrains.
the class AbstractRerunFailedTestsAction method isActive.
private boolean isActive(AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
return false;
}
TestFrameworkRunningModel model = getModel();
if (model == null || model.getRoot() == null) {
return false;
}
Filter filter = getFailuresFilter();
for (AbstractTestProxy test : model.getRoot().getAllTests()) {
//noinspection unchecked
if (filter.shouldAccept(test)) {
return true;
}
}
return false;
}
use of com.intellij.execution.testframework.AbstractTestProxy in project intellij-community by JetBrains.
the class ViewAssertEqualsDiffAction method openDiff.
public static boolean openDiff(DataContext context, @Nullable DiffHyperlink currentHyperlink) {
final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(context);
final Project project = CommonDataKeys.PROJECT.getData(context);
if (testProxy != null) {
DiffHyperlink diffViewerProvider = testProxy.getDiffViewerProvider();
if (diffViewerProvider != null) {
final List<DiffHyperlink> providers = collectAvailableProviders(TestTreeView.MODEL_DATA_KEY.getData(context));
int index = currentHyperlink != null ? providers.indexOf(currentHyperlink) : -1;
if (index == -1)
index = providers.indexOf(diffViewerProvider);
new MyDiffWindow(project, providers, Math.max(0, index)).show();
return true;
}
}
if (currentHyperlink != null) {
new MyDiffWindow(project, currentHyperlink).show();
return true;
}
return false;
}
use of com.intellij.execution.testframework.AbstractTestProxy in project intellij-community by JetBrains.
the class GradleRerunFailedTestsAction method getRunProfile.
@Nullable
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration) myConsoleProperties.getConfiguration();
final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
return new MyRunProfile(configuration) {
@NotNull
@Override
public Module[] getModules() {
return Module.EMPTY_ARRAY;
}
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
ExternalSystemRunConfiguration runProfile = ((ExternalSystemRunConfiguration) getPeer()).clone();
Project project = runProfile.getProject();
Set<String> scriptParameters = ContainerUtil.newLinkedHashSet();
Set<String> tasksToRun = ContainerUtil.newLinkedHashSet();
boolean useResolvedTasks = true;
for (AbstractTestProxy test : failedTests) {
if (test instanceof GradleSMTestProxy) {
String testName = test.getName();
String className = ((GradleSMTestProxy) test).getClassName();
scriptParameters.add(TestMethodGradleConfigurationProducer.createTestFilter(className, testName));
if (!useResolvedTasks)
continue;
if (className == null) {
useResolvedTasks = false;
continue;
}
final PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.projectScope(project));
if (psiClass == null) {
useResolvedTasks = false;
continue;
}
final PsiFile psiFile = psiClass.getContainingFile();
if (psiFile == null) {
useResolvedTasks = false;
continue;
}
final Module moduleForFile = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(psiFile.getVirtualFile());
if (moduleForFile == null) {
useResolvedTasks = false;
continue;
}
ContainerUtil.addAllNotNull(tasksToRun, GradleTestRunConfigurationProducer.getTasksToRun(moduleForFile));
}
}
runProfile.getSettings().setScriptParameters(StringUtil.join(scriptParameters, " "));
if (useResolvedTasks && !tasksToRun.isEmpty()) {
runProfile.getSettings().setTaskNames(ContainerUtil.newArrayList(tasksToRun));
}
return runProfile.getState(executor, environment);
}
};
}
use of com.intellij.execution.testframework.AbstractTestProxy 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));
}
}
};
}
};
}
};
}
Aggregations