You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2017/12/11 20:58:50 UTC
[geode] branch develop updated: GEODE-4073: Add ability for
SuiteRunner to interleave a candidate test class (#1150)
This is an automated email from the ASF dual-hosted git repository.
jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 57b9dbf GEODE-4073: Add ability for SuiteRunner to interleave a candidate test class (#1150)
57b9dbf is described below
commit 57b9dbf8f2e20e1e29c3357764565a2241e4b50d
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Mon Dec 11 12:58:48 2017 -0800
GEODE-4073: Add ability for SuiteRunner to interleave a candidate test class (#1150)
- By specifying a class with the annotation SuiteRunner.Candidate you can
interleave the candidate with each class defined in SuiteClasses.
---
.../geode/test/junit/runners/SuiteBlockRunner.java | 3 ++-
.../geode/test/junit/runners/SuiteRunner.java | 26 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteBlockRunner.java b/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteBlockRunner.java
index ef62077..e4663fa 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteBlockRunner.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteBlockRunner.java
@@ -39,6 +39,7 @@ public class SuiteBlockRunner extends BlockJUnit4ClassRunner {
@Override
protected String testName(FrameworkMethod method) {
- return method.getName() + "@" + suiteClass.getName();
+ // Some tests use the test name as the region name, so make sure we have valid chars
+ return method.getName() + "-" + suiteClass.getName().replace(".", "-");
}
}
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteRunner.java b/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteRunner.java
index dfa7b95..19bb530 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteRunner.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/runners/SuiteRunner.java
@@ -14,6 +14,11 @@
*/
package org.apache.geode.test.junit.runners;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.List;
@@ -33,6 +38,16 @@ import org.junit.runners.model.RunnerBuilder;
*/
public class SuiteRunner extends Suite {
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ @Inherited
+ public @interface Candidate {
+ /**
+ * @return the classes to be run
+ */
+ public Class<?> value();
+ }
+
public SuiteRunner(final Class<?> testClass, final RunnerBuilder builder)
throws InitializationError {
super(testClass, getRunners(testClass));
@@ -44,10 +59,21 @@ public class SuiteRunner extends Suite {
throw new InitializationError(
String.format("class '%s' must have a SuiteClasses annotation", testClass.getName()));
}
+
+ SuiteRunner.Candidate candidate = testClass.getAnnotation(Candidate.class);
+ Class<?> candidateClass = null;
+ if (candidate != null) {
+ candidateClass = candidate.value();
+ }
+
Class<?>[] childClasses = annotation.value();
List<Runner> runners = new ArrayList<>();
for (Class childClass : childClasses) {
runners.add(new SuiteBlockRunner(testClass, childClass));
+
+ if (candidateClass != null) {
+ runners.add(new SuiteBlockRunner(testClass, candidateClass));
+ }
}
return runners;
}
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].