Search in sources :

Example 1 with SMTestRunnerResultsForm

use of com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm in project intellij-community by JetBrains.

the class JavaTestFrameworkRunnableState method execute.

@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    final RunnerSettings runnerSettings = getRunnerSettings();
    final SMTRunnerConsoleProperties testConsoleProperties = getConfiguration().createTestConsoleProperties(executor);
    testConsoleProperties.setIfUndefined(TestConsoleProperties.HIDE_PASSED_TESTS, false);
    final BaseTestsOutputConsoleView consoleView = SMTestRunnerConnectionUtil.createConsole(getFrameworkName(), testConsoleProperties);
    final SMTestRunnerResultsForm viewer = ((SMTRunnerConsoleView) consoleView).getResultsViewer();
    Disposer.register(getConfiguration().getProject(), consoleView);
    final OSProcessHandler handler = createHandler(executor);
    consoleView.attachToProcess(handler);
    final AbstractTestProxy root = viewer.getRoot();
    if (root instanceof TestProxyRoot) {
        ((TestProxyRoot) root).setHandler(handler);
    }
    handler.addProcessListener(new ProcessAdapter() {

        @Override
        public void startNotified(ProcessEvent event) {
            if (getConfiguration().isSaveOutputToFile()) {
                final File file = OutputFileUtil.getOutputFile(getConfiguration());
                root.setOutputFilePath(file != null ? file.getAbsolutePath() : null);
            }
        }

        @Override
        public void processTerminated(ProcessEvent event) {
            Runnable runnable = () -> {
                root.flushOutputFile();
                deleteTempFiles();
                clear();
            };
            UIUtil.invokeLaterIfNeeded(runnable);
            handler.removeProcessListener(this);
        }
    });
    AbstractRerunFailedTestsAction rerunFailedTestsAction = testConsoleProperties.createRerunFailedTestsAction(consoleView);
    LOG.assertTrue(rerunFailedTestsAction != null);
    rerunFailedTestsAction.setModelProvider(() -> viewer);
    final DefaultExecutionResult result = new DefaultExecutionResult(consoleView, handler);
    result.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction() {

        @Override
        public boolean isDelayApplicable() {
            return false;
        }

        @Override
        public AbstractAutoTestManager getAutoTestManager(Project project) {
            return JavaAutoRunManager.getInstance(project);
        }
    });
    JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(getConfiguration(), handler, runnerSettings);
    return result;
}
Also used : SMTestRunnerResultsForm(com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) AbstractAutoTestManager(com.intellij.execution.testframework.autotest.AbstractAutoTestManager) GenericDebuggerRunnerSettings(com.intellij.debugger.impl.GenericDebuggerRunnerSettings) ProcessEvent(com.intellij.execution.process.ProcessEvent) AbstractRerunFailedTestsAction(com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction) ToggleAutoTestAction(com.intellij.execution.testframework.autotest.ToggleAutoTestAction) BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView) SMTRunnerConsoleProperties(com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) Project(com.intellij.openapi.project.Project) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with SMTestRunnerResultsForm

use of com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm in project intellij-community by JetBrains.

the class SMTestRunnerConnectionUtil method initConsoleView.

/** @deprecated use {@link #initConsoleView(SMTRunnerConsoleView, String)} (to be removed in IDEA 17) */
@SuppressWarnings({ "unused", "deprecation" })
public static void initConsoleView(@NotNull final SMTRunnerConsoleView consoleView, @NotNull final String testFrameworkName, @Nullable final TestLocationProvider locator, final boolean idBasedTreeConstruction, @Nullable final TestProxyFilterProvider filterProvider) {
    consoleView.addAttachToProcessListener(new AttachToProcessListener() {

        @Override
        public void onAttachToProcess(@NotNull ProcessHandler processHandler) {
            TestConsoleProperties properties = consoleView.getProperties();
            SMTestLocator testLocator = new CompositeTestLocationProvider(locator);
            TestProxyPrinterProvider printerProvider = null;
            if (filterProvider != null) {
                printerProvider = new TestProxyPrinterProvider(consoleView, filterProvider);
            }
            SMTestRunnerResultsForm resultsForm = consoleView.getResultsViewer();
            attachEventsProcessors(properties, resultsForm, processHandler, testFrameworkName, testLocator, idBasedTreeConstruction, printerProvider);
        }
    });
    consoleView.setHelpId("reference.runToolWindow.testResultsTab");
    consoleView.initUI();
}
Also used : SMTestRunnerResultsForm(com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm) AttachToProcessListener(com.intellij.execution.testframework.sm.runner.ui.AttachToProcessListener) ProcessHandler(com.intellij.execution.process.ProcessHandler) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties)

Example 3 with SMTestRunnerResultsForm

use of com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm in project intellij-community by JetBrains.

the class SMTestRunnerConnectionUtil method initConsoleView.

public static void initConsoleView(@NotNull final SMTRunnerConsoleView consoleView, @NotNull final String testFrameworkName) {
    consoleView.addAttachToProcessListener(new AttachToProcessListener() {

        @Override
        public void onAttachToProcess(@NotNull ProcessHandler processHandler) {
            TestConsoleProperties properties = consoleView.getProperties();
            TestProxyPrinterProvider printerProvider = null;
            if (properties instanceof SMTRunnerConsoleProperties) {
                TestProxyFilterProvider filterProvider = ((SMTRunnerConsoleProperties) properties).getFilterProvider();
                if (filterProvider != null) {
                    printerProvider = new TestProxyPrinterProvider(consoleView, filterProvider);
                }
            }
            SMTestLocator testLocator = FileUrlProvider.INSTANCE;
            if (properties instanceof SMTRunnerConsoleProperties) {
                SMTestLocator customLocator = ((SMTRunnerConsoleProperties) properties).getTestLocator();
                if (customLocator != null) {
                    testLocator = new CombinedTestLocator(customLocator);
                }
            }
            boolean idBasedTestTree = false;
            if (properties instanceof SMTRunnerConsoleProperties) {
                idBasedTestTree = ((SMTRunnerConsoleProperties) properties).isIdBasedTestTree();
            }
            SMTestRunnerResultsForm resultsForm = consoleView.getResultsViewer();
            attachEventsProcessors(properties, resultsForm, processHandler, testFrameworkName, testLocator, idBasedTestTree, printerProvider);
        }
    });
    consoleView.setHelpId("reference.runToolWindow.testResultsTab");
    consoleView.initUI();
}
Also used : SMTestRunnerResultsForm(com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm) AttachToProcessListener(com.intellij.execution.testframework.sm.runner.ui.AttachToProcessListener) ProcessHandler(com.intellij.execution.process.ProcessHandler) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties)

Aggregations

SMTestRunnerResultsForm (com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm)3 ProcessHandler (com.intellij.execution.process.ProcessHandler)2 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)2 AttachToProcessListener (com.intellij.execution.testframework.sm.runner.ui.AttachToProcessListener)2 GenericDebuggerRunnerSettings (com.intellij.debugger.impl.GenericDebuggerRunnerSettings)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 AbstractRerunFailedTestsAction (com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction)1 AbstractAutoTestManager (com.intellij.execution.testframework.autotest.AbstractAutoTestManager)1 ToggleAutoTestAction (com.intellij.execution.testframework.autotest.ToggleAutoTestAction)1 SMTRunnerConsoleProperties (com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties)1 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)1 BaseTestsOutputConsoleView (com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView)1 Project (com.intellij.openapi.project.Project)1 NotNull (org.jetbrains.annotations.NotNull)1