MyRunProfile (@NotNull ExecutionEnvironment environment) { final TestNGConfiguration configuration = (TestNGConfiguration)myConsoleProperties.getConfiguration(); final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject()); return new MyRunProfile(configuration) { @Override public Module @NotNull [] getModules() { return configuration.getModules(); } @Override public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) { return new TestNGRunnableState(env, configuration) { @Override public SearchForTestsTask createSearchingForTestsTask() { return createSearchingForTestsTask(new LocalTargetEnvironment(new LocalTargetEnvironmentRequest())); } @Override public SearchForTestsTask createSearchingForTestsTask(@NotNull TargetEnvironment targetEnvironment) { return new SearchingForTestsTask(getServerSocket(), getConfiguration(), myTempFile) { @Override protected void fillTestObjects(final Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException { final HashMap<PsiClass, Map<PsiMethod, List<String>>> fullClassList = new HashMap<>(); super.fillTestObjects(fullClassList); for (final PsiClass aClass : fullClassList.keySet()) { if (!ReadAction.compute(() -> TestNGUtil.hasTest(aClass))) { classes.put(aClass, fullClassList.get(aClass)); } } final GlobalSearchScope scope = getConfiguration().getConfigurationModule().getSearchScope(); final Project project = getConfiguration().getProject(); for (final AbstractTestProxy proxy : failedTests) { ApplicationManager.getApplication().runReadAction(() -> includeFailedTestWithDependencies(classes, scope, project, proxy)); } } }; } }; } }; }