@Override
 public void actionPerformed(AnActionEvent e) {
   final Project project = e.getProject();
   LOG.assertTrue(project != null);
   final VirtualFile file = getFile(project);
   if (file != null) {
     try {
       final ImportRunProfile profile = new ImportRunProfile(file, project);
       SMTRunnerConsoleProperties properties = profile.getProperties();
       if (properties == null) {
         properties = myProperties;
         LOG.info(
             "Failed to detect test framework in "
                 + file.getPath()
                 + "; use "
                 + (properties != null
                     ? properties.getTestFrameworkName() + " from toolbar"
                     : "no properties"));
       }
       final Executor executor =
           properties != null
               ? properties.getExecutor()
               : ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
       ExecutionEnvironmentBuilder builder =
           ExecutionEnvironmentBuilder.create(project, executor, profile);
       final RunConfiguration initialConfiguration = profile.getInitialConfiguration();
       final ProgramRunner runner =
           initialConfiguration != null
               ? RunnerRegistry.getInstance().getRunner(executor.getId(), initialConfiguration)
               : null;
       if (runner != null) {
         builder = builder.runner(runner);
       }
       builder.buildAndExecute();
     } catch (ExecutionException e1) {
       Messages.showErrorDialog(project, e1.getMessage(), "Import Failed");
     }
   }
 }
  protected ExecutionResult startSMRunner(Executor executor) throws ExecutionException {
    if (!isSmRunnerUsed()) {
      return null;
    }
    getJavaParameters()
        .getVMParametersList()
        .addProperty("idea." + getFrameworkId() + ".sm_runner");

    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);
    handler.addProcessListener(
        new ProcessAdapter() {
          @Override
          public void startNotified(ProcessEvent event) {
            if (getConfiguration().isSaveOutputToFile()) {
              viewer.getRoot().setOutputFilePath(getConfiguration().getOutputFilePath());
            }
          }

          @Override
          public void processTerminated(ProcessEvent event) {
            Runnable runnable =
                new Runnable() {
                  public void run() {
                    viewer.getRoot().flush();
                    deleteTempFiles();
                    clear();
                  }
                };
            UIUtil.invokeLaterIfNeeded(runnable);
            handler.removeProcessListener(this);
          }
        });

    AbstractRerunFailedTestsAction rerunFailedTestsAction =
        testConsoleProperties.createRerunFailedTestsAction(consoleView);
    LOG.assertTrue(rerunFailedTestsAction != null);
    rerunFailedTestsAction.setModelProvider(
        new Getter<TestFrameworkRunningModel>() {
          @Override
          public TestFrameworkRunningModel get() {
            return viewer;
          }
        });

    final DefaultExecutionResult result = new DefaultExecutionResult(consoleView, handler);
    result.setRestartActions(rerunFailedTestsAction);

    JavaRunConfigurationExtensionManager.getInstance()
        .attachExtensionsToProcess(getConfiguration(), handler, runnerSettings);
    return result;
  }
 @Nullable
 @Override
 public Icon getIcon() {
   return myProperties != null ? myProperties.getConfiguration().getIcon() : null;
 }