Ejemplo n.º 1
0
 public String suggestActionName() {
   final String configurationName = myConfiguration.getName();
   if (!myConfiguration.isGeneratedName()) {
     return "'" + configurationName + "'";
   }
   final JUnitConfiguration.Data data = myConfiguration.getPersistentData();
   if (data.getPackageName().trim().length() > 0) {
     return ExecutionBundle.message("test.in.scope.presentable.text", data.getPackageName());
   }
   return ExecutionBundle.message("all.tests.scope.presentable.text");
 }
Ejemplo n.º 2
0
 protected PsiPackage getPackage(JUnitConfiguration.Data data) throws CantRunException {
   final Project project = myConfiguration.getProject();
   final String packageName = data.getPackageName();
   final PsiManager psiManager = PsiManager.getInstance(project);
   final PsiPackage aPackage =
       JavaPsiFacade.getInstance(psiManager.getProject()).findPackage(packageName);
   if (aPackage == null) throw CantRunException.packageNotFound(packageName);
   return aPackage;
 }
Ejemplo n.º 3
0
 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);
 }