コード例 #1
0
 @Nullable
 @Override
 public RunProfileState getState(
     @NotNull Executor executor, @NotNull ExecutionEnvironment environment)
     throws ExecutionException {
   if (!myImported) {
     myImported = true;
     return new ImportedTestRunnableState(this, VfsUtilCore.virtualToIoFile(myFile));
   }
   if (myConfiguration != null) {
     try {
       return myConfiguration.getState(executor, environment);
     } catch (Throwable e) {
       LOG.info(e);
       throw new ExecutionException("Unable to run the configuration: settings are corrupted");
     }
   }
   throw new ExecutionException(
       "Unable to run the configuration: failed to detect test framework");
 }
コード例 #2
0
  private void checkCantRun(RunConfiguration configuration, String reasonBeginning)
      throws ExecutionException {
    // MockRunRequest request = new MockRunRequest(myProject);
    // CantRunException rejectReason;
    // try {
    //  configuration.runRequested(request);
    //  rejectReason = request.myRejectReason;
    // }
    // catch (CantRunException e) {
    //  rejectReason = e;
    // }
    // if (rejectReason == null) fail("Should not run");
    // rejectReason.getMessage().startsWith(reasonBeginning);

    try {
      configuration.checkConfiguration();
    } catch (RuntimeConfigurationError e) {
      assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning));
      return;
    } catch (RuntimeConfigurationException ignored) {

    }

    RunProfileState state =
        configuration.getState(
            DefaultRunExecutor.getRunExecutorInstance(),
            new ExecutionEnvironmentBuilder(myProject, DefaultRunExecutor.getRunExecutorInstance())
                .runProfile(configuration)
                .build());
    assertTrue(state instanceof JavaCommandLine);

    try {
      ((JavaCommandLine) state).getJavaParameters();
    } catch (Throwable e) {
      assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning));
      return;
    }

    fail("Should not run");
  }