コード例 #1
0
  @Override
  public MyRunProfile getRunProfile() {
    final TestNGConfiguration configuration =
        (TestNGConfiguration) getModel().getProperties().getConfiguration();
    final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
    return new MyRunProfile(configuration) {
      @NotNull
      public Module[] getModules() {
        return Module.EMPTY_ARRAY;
      }

      public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env)
          throws ExecutionException {

        return new TestNGRunnableState(env, configuration) {
          @Override
          protected SearchingForTestsTask createSearchingForTestsTask(
              ServerSocket serverSocket, final TestNGConfiguration config, final File tempFile) {
            return new SearchingForTestsTask(serverSocket, config, tempFile, client) {
              @Override
              protected void fillTestObjects(final Map<PsiClass, Collection<PsiMethod>> classes)
                  throws CantRunException {
                for (AbstractTestProxy proxy : failedTests) {
                  final Location location = proxy.getLocation(config.getProject());
                  if (location != null) {
                    final PsiElement element = location.getPsiElement();
                    if (element instanceof PsiMethod && element.isValid()) {
                      final PsiMethod psiMethod = (PsiMethod) element;
                      final PsiClass psiClass = psiMethod.getContainingClass();
                      Collection<PsiMethod> psiMethods = classes.get(psiClass);
                      if (psiMethods == null) {
                        psiMethods = new ArrayList<PsiMethod>();
                        classes.put(psiClass, psiMethods);
                      }
                      psiMethods.add(psiMethod);
                    }
                  }
                }
              }
            };
          }
        };
      }
    };
  }
コード例 #2
0
  private boolean configure(
      TestNGConfiguration configuration,
      Location location,
      ConfigurationContext context,
      Project project,
      @Nullable PsiClass delegate,
      @Nullable PsiMethod method) {
    if (delegate == null) {
      return false;
    }

    setupConfigurationModule(context, configuration);
    Module originalModule = configuration.getConfigurationModule().getModule();
    configuration.setClassConfiguration(delegate);
    if (method != null) {
      configuration.setMethodConfiguration(PsiLocation.fromPsiElement(project, method));
    }
    configuration.restoreOriginalModule(originalModule);
    configuration.setName(configuration.getName());
    JavaRunConfigurationExtensionManager.getInstance()
        .extendCreatedConfiguration(configuration, location);
    return true;
  }
 @Override
 protected Set<String> getPatterns(TestNGConfiguration configuration) {
   return configuration.getPersistantData().getPatterns();
 }
 @Override
 protected boolean isPatternBasedConfiguration(TestNGConfiguration configuration) {
   return TestType.PATTERN.getType().equals(configuration.getPersistantData().TEST_OBJECT);
 }