public void configureClasspath(final JavaParameters javaParameters) throws CantRunException { RunConfigurationModule module = getConfigurationModule(); final String jreHome = isAlternativeJrePathEnabled() ? getAlternativeJrePath() : null; final int pathType = JavaParameters.JDK_AND_CLASSES_AND_TESTS; if (myData.getScope() == TestSearchScope.WHOLE_PROJECT) { JavaParametersUtil.configureProject(module.getProject(), javaParameters, pathType, jreHome); } else { JavaParametersUtil.configureModule(module, javaParameters, pathType, jreHome); } }
protected void initialize() throws ExecutionException { defaultInitialize(); final JUnitConfiguration.Data data = myConfiguration.getPersistentData(); RunConfigurationModule module = myConfiguration.getConfigurationModule(); final Project project = module.getProject(); addJUnit4Parameter(data, project); final ExecutionException[] exception = new ExecutionException[1]; ApplicationManager.getApplication() .runReadAction( new Runnable() { public void run() { try { myConfiguration.configureClasspath(myJavaParameters); } catch (CantRunException e) { exception[0] = e; } } }); if (exception[0] != null) throw exception[0]; final LinkedHashMap<PsiMethod, TestInfo> methods = new LinkedHashMap<PsiMethod, TestInfo>(); for (AbstractTestProxy failedTest : myFailedTests) { Location location = failedTest.getLocation(project); if (!(location instanceof MethodLocation)) continue; PsiElement psiElement = location.getPsiElement(); LOG.assertTrue(psiElement instanceof PsiMethod); PsiMethod method = (PsiMethod) psiElement; methods.put(method, ((TestProxy) failedTest).getInfo()); } addClassesListToJavaParameters( methods.keySet(), new Function<PsiElement, String>() { public String fun(PsiElement element) { if (element instanceof PsiMethod) { final PsiMethod method = (PsiMethod) element; final TestInfo testInfo = methods.get(method); return JavaExecutionUtil.getRuntimeQualifiedName( ((MethodLocation) testInfo.getLocation(project)).getContainingClass()) + "," + testInfo.getName(); } return null; } }, data.getPackageName(), true, false); }
private static String getConfigurationName(PsiClass aClass, RunConfigurationModule module) { String qualifiedName = aClass.getQualifiedName(); Project project = module.getProject(); if (qualifiedName != null) { PsiClass psiClass = JavaPsiFacade.getInstance(project) .findClass(qualifiedName.replace('$', '.'), GlobalSearchScope.projectScope(project)); if (psiClass != null) { return psiClass.getName(); } else { int lastDot = qualifiedName.lastIndexOf('.'); if (lastDot == -1 || lastDot == qualifiedName.length() - 1) { return qualifiedName; } return qualifiedName.substring(lastDot + 1, qualifiedName.length()); } } return module.getModuleName(); }