Search in sources :

Example 1 with SMTestRunnerConnectionUtil

use of com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil in project intellij-elixir by KronicDeth.

the class MixExUnitRunningState method createAndAttachConsole.

/**
   * Unifies the interface for {@code SMTestRunnerConnectionUtil.createAndAttachConsole} between 141 and later releases
   */
private ConsoleView createAndAttachConsole(@NotNull String testFrameworkName, @NotNull ProcessHandler processHandler, @NotNull TestConsoleProperties consoleProperties) throws ExecutionException {
    Class<SMTestRunnerConnectionUtil> klass = SMTestRunnerConnectionUtil.class;
    ConsoleView consoleView = null;
    try {
        Method createAndAttachConsole = klass.getMethod("createAndAttachConsole", String.class, ProcessHandler.class, TestConsoleProperties.class);
        try {
            consoleView = (ConsoleView) createAndAttachConsole.invoke(null, testFrameworkName, processHandler, consoleProperties);
        } catch (IllegalAccessException | InvocationTargetException e) {
            LOGGER.error(e);
        }
    } catch (NoSuchMethodException noSuchCreateAndAttachConsole3Method) {
        try {
            Method createAndAttachConsole = klass.getMethod("createAndAttachConsole", String.class, ProcessHandler.class, TestConsoleProperties.class, ExecutionEnvironment.class);
            try {
                consoleView = (ConsoleView) createAndAttachConsole.invoke(null, testFrameworkName, processHandler, consoleProperties, getEnvironment());
            } catch (IllegalAccessException | InvocationTargetException e) {
                LOGGER.error(e);
            }
        } catch (NoSuchMethodException noSuchCreateAndAttachConsole4Method) {
            noSuchCreateAndAttachConsole4Method.printStackTrace();
        }
    }
    return consoleView;
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ConsoleView(com.intellij.execution.ui.ConsoleView) SMTestRunnerConnectionUtil(com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil) ProcessHandler(com.intellij.execution.process.ProcessHandler) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties)

Aggregations

ProcessHandler (com.intellij.execution.process.ProcessHandler)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)1 SMTestRunnerConnectionUtil (com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1