Search in sources :

Example 1 with BaseTestsOutputConsoleView

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

the class PythonTestCommandLineStateBase method execute.

@Override
public ExecutionResult execute(Executor executor, PythonProcessStarter processStarter, CommandLinePatcher... patchers) throws ExecutionException {
    final ProcessHandler processHandler = startProcess(processStarter, patchers);
    final ConsoleView console = createAndAttachConsole(myConfiguration.getProject(), processHandler, executor);
    DefaultExecutionResult executionResult = new DefaultExecutionResult(console, processHandler, createActions(console, processHandler));
    PyRerunFailedTestsAction rerunFailedTestsAction = new PyRerunFailedTestsAction(console);
    if (console instanceof SMTRunnerConsoleView) {
        rerunFailedTestsAction.init(((BaseTestsOutputConsoleView) console).getProperties());
        rerunFailedTestsAction.setModelProvider(() -> ((SMTRunnerConsoleView) console).getResultsViewer());
    }
    executionResult.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction());
    return executionResult;
}
Also used : SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView) ConsoleView(com.intellij.execution.ui.ConsoleView) PythonDebugLanguageConsoleView(com.jetbrains.python.console.PythonDebugLanguageConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) ToggleAutoTestAction(com.intellij.execution.testframework.autotest.ToggleAutoTestAction)

Example 2 with BaseTestsOutputConsoleView

use of com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView 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 3 with BaseTestsOutputConsoleView

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

the class ImportedTestRunnableState method execute.

@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    final MyEmptyProcessHandler handler = new MyEmptyProcessHandler();
    final SMTRunnerConsoleProperties properties = myRunProfile.getProperties();
    RunProfile configuration;
    final String frameworkName;
    if (properties != null) {
        configuration = properties.getConfiguration();
        frameworkName = properties.getTestFrameworkName();
    } else {
        configuration = myRunProfile;
        frameworkName = "Import Test Results";
    }
    final ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(properties, myFile, handler, myRunProfile.getProject(), configuration, frameworkName, executor);
    final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(consoleProperties.getTestFrameworkName(), consoleProperties);
    final JComponent component = console.getComponent();
    AbstractRerunFailedTestsAction rerunFailedTestsAction = null;
    if (component instanceof TestFrameworkRunningModel) {
        rerunFailedTestsAction = consoleProperties.createRerunFailedTestsAction(console);
        if (rerunFailedTestsAction != null) {
            rerunFailedTestsAction.setModelProvider(() -> (TestFrameworkRunningModel) component);
        }
    }
    console.attachToProcess(handler);
    final DefaultExecutionResult result = new DefaultExecutionResult(console, handler);
    if (rerunFailedTestsAction != null) {
        result.setRestartActions(rerunFailedTestsAction);
    }
    return result;
}
Also used : TestFrameworkRunningModel(com.intellij.execution.testframework.TestFrameworkRunningModel) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) AbstractRerunFailedTestsAction(com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction) RunProfile(com.intellij.execution.configurations.RunProfile) BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView) SMTRunnerConsoleProperties(com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with BaseTestsOutputConsoleView

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

the class SMTestRunnerConnectionUtil method createAndAttachConsole.

/**
   * Creates Test Runner console component with test tree, console, statistics tabs
   * and attaches it to given Process handler.
   * <p/>
   * You can use this method in run configuration's CommandLineState. You should
   * just override "execute" method of your custom command line state and return
   * test runner's console.
   * <p/>
   * E.g: <pre>{@code
   * public class MyCommandLineState extends CommandLineState {
   *
   *   // ...
   *
   *   @Override
   *   public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
   *     ProcessHandler processHandler = startProcess();
   *     RunConfiguration runConfiguration = getConfiguration();
   *     ExecutionEnvironment environment = getEnvironment();
   *     TestConsoleProperties properties = new SMTRunnerConsoleProperties(runConfiguration, "xUnit", executor)
   *     ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("xUnit", processHandler, properties, environment);
   *     return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler));
   *   }
   * }
   * }</pre>
   * <p/>
   * NB: For debug purposes please enable "debug mode". In this mode test runner will also validate
   * consistency of test events communication protocol and throw assertion errors. To enable debug mode
   * please set system property idea.smrunner.debug=true
   *
   * @param testFrameworkName Is used to store(project level) latest value of testTree/consoleTab splitter and other settings
   *                          and also will be mentioned in debug diagnostics
   * @param processHandler    Process handler
   * @param consoleProperties Console properties for test console actions
   * @return Console view
   * @throws ExecutionException If IDEA cannot execute process this exception will
   *                            be caught and shown in error message box
   */
@NotNull
public static BaseTestsOutputConsoleView createAndAttachConsole(@NotNull String testFrameworkName, @NotNull ProcessHandler processHandler, @NotNull TestConsoleProperties consoleProperties) throws ExecutionException {
    BaseTestsOutputConsoleView console = createConsole(testFrameworkName, consoleProperties);
    console.attachToProcess(processHandler);
    return console;
}
Also used : BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with BaseTestsOutputConsoleView

use of com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView in project intellij-plugins by JetBrains.

the class CfmlUnitRunConfiguration method createConsole.

private ConsoleView createConsole(Project project, ProcessHandler processHandler, ExecutionEnvironment env, Executor executor) throws ExecutionException {
    final CfmlUnitRunConfiguration runConfiguration = (CfmlUnitRunConfiguration) env.getRunProfile();
    final CfmlUnitConsoleProperties consoleProps = new CfmlUnitConsoleProperties(runConfiguration, executor);
    consoleProps.addStackTraceFilter(new CfmlStackTraceFilterProvider(getProject()));
    BaseTestsOutputConsoleView testsOutputConsoleView = SMTestRunnerConnectionUtil.createAndAttachConsole("Cfml", processHandler, consoleProps);
    Disposer.register(project, testsOutputConsoleView);
    return testsOutputConsoleView;
}
Also used : BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView)

Aggregations

BaseTestsOutputConsoleView (com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView)6 SMTRunnerConsoleProperties (com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties)3 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)2 AbstractRerunFailedTestsAction (com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction)2 ToggleAutoTestAction (com.intellij.execution.testframework.autotest.ToggleAutoTestAction)2 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)2 NotNull (org.jetbrains.annotations.NotNull)2 GenericDebuggerRunnerSettings (com.intellij.debugger.impl.GenericDebuggerRunnerSettings)1 RunProfile (com.intellij.execution.configurations.RunProfile)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 TestFrameworkRunningModel (com.intellij.execution.testframework.TestFrameworkRunningModel)1 AbstractAutoTestManager (com.intellij.execution.testframework.autotest.AbstractAutoTestManager)1 SMTestRunnerResultsForm (com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 FlexStackTraceFilter (com.intellij.lang.javascript.flex.FlexStackTraceFilter)1 Project (com.intellij.openapi.project.Project)1 PythonDebugLanguageConsoleView (com.jetbrains.python.console.PythonDebugLanguageConsoleView)1