aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2016-07-20 15:17:02 +0100
committerPaul Duffin <paulduffin@google.com>2016-07-20 15:29:55 +0100
commit67bea903e940b78438a4d95bf54d4787e3aac0b0 (patch)
treecfa9ffb2a81eb358fe74c8129640a3c766e9f0c0
parentf60f4ca1e64958be1baa4988ac48f97903d14eaf (diff)
downloadplatform_external_junit-params-67bea903e940b78438a4d95bf54d4787e3aac0b0.tar.gz
platform_external_junit-params-67bea903e940b78438a4d95bf54d4787e3aac0b0.tar.bz2
platform_external_junit-params-67bea903e940b78438a4d95bf54d4787e3aac0b0.zip
Fix dependency on undefined order of Class.getMethods()
The Class.getMethods() returns an array of methods from a class and its interfaces and super class but specifies that the order is undefined. The affected test indexes the array using an index of 0, presumably because it assumes that the method defined in the class comes before methods defined in the super class and interfaces. This is a bug in the upstream repository and is separated out from the other patches to make it easier to push it to the upstream repository. Bug: 30244565 Change-Id: I9e267b53614a46497e04c73841d086b83b536570 Test: Once it compiles the tests will be run.
-rw-r--r--src/test/java/junitparams/ParametersReaderProvidersTest.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/test/java/junitparams/ParametersReaderProvidersTest.java b/src/test/java/junitparams/ParametersReaderProvidersTest.java
index d3992b6..c4a2bb8 100644
--- a/src/test/java/junitparams/ParametersReaderProvidersTest.java
+++ b/src/test/java/junitparams/ParametersReaderProvidersTest.java
@@ -42,8 +42,14 @@ public class ParametersReaderProvidersTest {
}
private TestMethod getTestMethodWithInvalidProvider() {
- Method testMethod = TestClassWithProviderClassWithNoValidMethods.class.getMethods()[0];
- return new TestMethod(new FrameworkMethod(testMethod), new TestClass(TestClassWithProviderClassWithNoValidMethods.class));
+ // Bug in original code relied on order of Class.getMethods() which is undefined.
+ try {
+ Method testMethod = TestClassWithProviderClassWithNoValidMethods.class
+ .getDeclaredMethod("shouldDoNothingItsJustToConnectTestClassWithProvider");
+ return new TestMethod(new FrameworkMethod(testMethod), new TestClass(TestClassWithProviderClassWithNoValidMethods.class));
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Mismatch between method and test class", e);
+ }
}
@RunWith(JUnitParamsRunner.class)