diff options
Diffstat (limited to 'plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java')
-rw-r--r-- | plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java index 413aceebf8d4..2258b16a7a2a 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java @@ -191,11 +191,22 @@ public class SearchingForTestsTask extends Task.Backgroundable { private void composeTestSuiteFromClasses() { Map<String, Collection<String>> map = new HashMap<String, Collection<String>>(); + + final boolean findTestMethodsForClass = shouldSearchForTestMethods(); + for (final Map.Entry<PsiClass, Collection<PsiMethod>> entry : myClasses.entrySet()) { - Collection<String> methods = new HashSet<String>(entry.getValue().size()); - for (PsiMethod method : entry.getValue()) { + final Collection<PsiMethod> depMethods = entry.getValue(); + Collection<String> methods = new HashSet<String>(depMethods.size()); + for (PsiMethod method : depMethods) { methods.add(method.getName()); } + if (findTestMethodsForClass && depMethods.isEmpty()) { + for (PsiMethod method : entry.getKey().getMethods()) { + if (TestNGUtil.hasTest(method)) { + methods.add(method.getName()); + } + } + } map.put(ApplicationManager.getApplication().runReadAction( new Computable<String>() { @Nullable @@ -243,6 +254,17 @@ public class SearchingForTestsTask extends Task.Backgroundable { } } + private boolean shouldSearchForTestMethods() { + boolean dependantMethods = false; + for (Collection<PsiMethod> methods : myClasses.values()) { + if (!methods.isEmpty()) { + dependantMethods = true; + break; + } + } + return dependantMethods; + } + private void composeTestSuiteFromXml() throws CantRunException { final Map<String, String> buildTestParams = buildTestParameters(); try { |