Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2991)

Unified Diff: base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java

Issue 2273553002: Create BaseJUnitClassRunner to run junit4 style tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change after +jbudorick's comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java
diff --git a/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java b/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java
index efca73402ebd05f289498f397dbf05c6a0eb70e6..9cc96dc14c39edaa1d8711a7279b37db34a14d9b 100644
--- a/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java
+++ b/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java
@@ -10,6 +10,7 @@ import org.chromium.testing.local.LocalRobolectricTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.model.FrameworkMethod;
import org.robolectric.annotation.Config;
import java.lang.annotation.Annotation;
@@ -30,8 +31,12 @@ public class SkipCheckTest {
return getAnnotations(element, annotationClass);
}
+ public static FrameworkMethod getTestFrameworkMethodForTesting(TestCase testCase) {
+ return getTestFrameworkMethod(testCase);
+ }
+
@Override
- public boolean shouldSkip(TestCase t) {
+ public boolean shouldSkip(FrameworkMethod m) {
return false;
}
}
@@ -39,11 +44,6 @@ public class SkipCheckTest {
@Retention(RetentionPolicy.RUNTIME)
private @interface TestAnnotation {}
- private class UnannotatedBaseClass {
- public void unannotatedMethod() {}
- @TestAnnotation public void annotatedMethod() {}
- }
-
@TestAnnotation
private class AnnotatedBaseClass {
public void unannotatedMethod() {}
@@ -54,6 +54,18 @@ public class SkipCheckTest {
public void anotherUnannotatedMethod() {}
}
+ private class ExtendsTestCaseClass extends TestCase {
+ public ExtendsTestCaseClass(String name) {
+ super(name);
+ }
+ public void testMethodA() {}
+ }
+
+ private class UnannotatedBaseClass {
+ public void unannotatedMethod() {}
+ @TestAnnotation public void annotatedMethod() {}
+ }
+
@Test
public void getAnnotationsForClassNone() {
List<TestAnnotation> annotations = TestableSkipCheck.getAnnotationsForTesting(
@@ -120,4 +132,20 @@ public class SkipCheckTest {
Assert.assertEquals(2, annotations.size());
}
+ @Test
+ public void getExistingTestFrameworkMethod() {
+ String testMethodName = "testMethodA";
+ ExtendsTestCaseClass testCase = new ExtendsTestCaseClass(testMethodName);
+ FrameworkMethod method = TestableSkipCheck.getTestFrameworkMethodForTesting(testCase);
+ Assert.assertNotNull(method);
+ Assert.assertTrue(testMethodName.equals(method.getName()));
+ }
+
+ @Test
+ public void getNoneTestFrameworkMethod() {
+ String testMethodName = "noSuchTestMethod";
+ ExtendsTestCaseClass testCase = new ExtendsTestCaseClass(testMethodName);
+ FrameworkMethod method = TestableSkipCheck.getTestFrameworkMethodForTesting(testCase);
+ Assert.assertNull(method);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698