summaryrefslogtreecommitdiff
path: root/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-09-04 13:25:33 -0700
committerTor Norbye <tnorbye@google.com>2014-09-04 13:25:33 -0700
commitd245f58efbfc26b13b9b9d5e52e6a83a0d76216c (patch)
treebca7d49005d81d10c70bc3f547df041c636b4300 /plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java
parent9cde0e3c015174898df8b8f3672185941fad4786 (diff)
parentc3d3a90f6b4ead083d63e28e6b9fcea93d675678 (diff)
downloadidea-d245f58efbfc26b13b9b9d5e52e6a83a0d76216c.tar.gz
Merge remote-tracking branch 'aosp/upstream-master' into merge
Diffstat (limited to 'plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java')
-rw-r--r--plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java26
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 {