junit/testng: pattern configuration isValid respect to chosen method
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 1 Feb 2012 07:58:23 +0000 (11:58 +0400)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 1 Feb 2012 07:59:41 +0000 (11:59 +0400)
plugins/junit/src/com/intellij/execution/junit/TestsPattern.java
plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java

index 01527b71fde390a6a440c44ddacbae51b09333fd..6a55ca17374bfcc2482930d15694dbf32902c6c5 100644 (file)
@@ -122,12 +122,13 @@ public class TestsPattern extends TestObject {
     }
     final GlobalSearchScope searchScope = GlobalSearchScope.allScope(myConfiguration.getProject());
     for (String pattern : patterns) {
     }
     final GlobalSearchScope searchScope = GlobalSearchScope.allScope(myConfiguration.getProject());
     for (String pattern : patterns) {
-      final PsiClass psiClass = JavaExecutionUtil.findMainClass(myConfiguration.getProject(), pattern, searchScope);
+      final String className = pattern.contains(",") ? StringUtil.getPackageName(pattern, ',') : pattern;
+      final PsiClass psiClass = JavaExecutionUtil.findMainClass(myConfiguration.getProject(), className, searchScope);
       if (psiClass == null) {
       if (psiClass == null) {
-        throw new RuntimeConfigurationWarning("Class " + pattern + " not found");
+        throw new RuntimeConfigurationWarning("Class " + className + " not found");
       }
       if (!JUnitUtil.isTestClass(psiClass)) {
       }
       if (!JUnitUtil.isTestClass(psiClass)) {
-        throw new RuntimeConfigurationWarning("Class " + pattern + " not a test");
+        throw new RuntimeConfigurationWarning("Class " + className + " not a test");
       }
     }
   }
       }
     }
   }
index 92a67174157c5aa66e2e1aa0a4013bb4a325e8ef..27054e0de6573cb39078943452c8f7fa9a8f9582 100644 (file)
@@ -39,6 +39,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.DefaultJDOMExternalizer;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.openapi.util.DefaultJDOMExternalizer;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.refactoring.listeners.RefactoringElementAdapter;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.refactoring.listeners.RefactoringElementAdapter;
@@ -330,12 +331,13 @@ public class TestNGConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
       }
       final GlobalSearchScope searchScope = GlobalSearchScope.allScope(getProject());
       for (String pattern : patterns) {
       }
       final GlobalSearchScope searchScope = GlobalSearchScope.allScope(getProject());
       for (String pattern : patterns) {
-        final PsiClass psiClass = JavaExecutionUtil.findMainClass(getProject(), pattern, searchScope);
+        final String className = pattern.contains(",") ? StringUtil.getPackageName(pattern, ',') : pattern;
+        final PsiClass psiClass = JavaExecutionUtil.findMainClass(getProject(), className, searchScope);
         if (psiClass == null) {
         if (psiClass == null) {
-          throw new RuntimeConfigurationWarning("Class " + pattern + " not found");
+          throw new RuntimeConfigurationWarning("Class " + className + " not found");
         }
         if (!TestNGUtil.hasTest(psiClass)) {
         }
         if (!TestNGUtil.hasTest(psiClass)) {
-          throw new RuntimeConfigurationWarning("Class " + pattern + " not a test");
+          throw new RuntimeConfigurationWarning("Class " + className + " not a test");
         }
       }
     }
         }
       }
     }