aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/junitparams/FilterableTest.java15
-rw-r--r--src/test/java/junitparams/ParametersReaderProvidersTest.java5
-rw-r--r--src/test/java/junitparams/SamplesOfUsageVerificationTest.java5
-rw-r--r--src/test/java/junitparams/internal/TestMethodTest.java12
-rw-r--r--src/test/java/junitparams/naming/MacroSubstitutionNamingStrategyTest.java4
-rw-r--r--src/test/java/junitparams/naming/NamingStrategyIsUsedByRunnerTest.java4
-rw-r--r--src/test/java/junitparams/usage/SamplesOfUsageTest.java15
-rw-r--r--src/test/java/junitparams/usage/person_example/PersonTest.java3
8 files changed, 53 insertions, 10 deletions
diff --git a/src/test/java/junitparams/FilterableTest.java b/src/test/java/junitparams/FilterableTest.java
index 05b2b4c..97e1ea4 100644
--- a/src/test/java/junitparams/FilterableTest.java
+++ b/src/test/java/junitparams/FilterableTest.java
@@ -6,6 +6,7 @@ import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
import org.junit.runner.Result;
import org.junit.runner.manipulation.Filter;
+import org.junit.runner.manipulation.NoTestsRemainException;
import static org.assertj.core.api.Assertions.*;
@@ -58,6 +59,20 @@ public class FilterableTest {
assertThat(description.getChildren().get(0).getChildren()).hasSize(2);
}
+ @Test
+ public void shouldApplyFiltersCumulatively() throws Exception {
+ JUnitParamsRunner runner = new JUnitParamsRunner(SampleTestCase.class);
+ // Remove the first method.
+ new SingleMethodFilter("firstTestMethod").apply(runner);
+ try {
+ // Now remove all instances of the second method.
+ new SingleMethodFilter("secondTestMethod").apply(runner);
+ fail("Filtering did not apply cumulatively");
+ } catch (NoTestsRemainException expected) {
+ // expected
+ }
+ }
+
private Request requestSingleMethodRun(Class<SampleTestCase> clazz, String methodName) {
return Request.aClass(clazz).filterWith(new SingleMethodFilter(methodName));
}
diff --git a/src/test/java/junitparams/ParametersReaderProvidersTest.java b/src/test/java/junitparams/ParametersReaderProvidersTest.java
index c4a2bb8..8b4297f 100644
--- a/src/test/java/junitparams/ParametersReaderProvidersTest.java
+++ b/src/test/java/junitparams/ParametersReaderProvidersTest.java
@@ -1,6 +1,5 @@
package junitparams;
-import junitparams.internal.ParameterisedTestMethodRunner;
import junitparams.internal.TestMethod;
import org.junit.Rule;
import org.junit.Test;
@@ -34,11 +33,11 @@ public class ParametersReaderProvidersTest {
@Test
public void shouldPutProviderClassNameInExceptionMessageForProviderWithNoValidMethods() {
- ParameterisedTestMethodRunner runner = new ParameterisedTestMethodRunner(getTestMethodWithInvalidProvider());
+ TestMethod testMethod = getTestMethodWithInvalidProvider();
exception.expect(RuntimeException.class);
exception.expectMessage(ProviderClassWithNoValidMethods.class.getName());
- runner.method.parametersSets();
+ testMethod.parametersSets();
}
private TestMethod getTestMethodWithInvalidProvider() {
diff --git a/src/test/java/junitparams/SamplesOfUsageVerificationTest.java b/src/test/java/junitparams/SamplesOfUsageVerificationTest.java
index a485d4e..459a0cd 100644
--- a/src/test/java/junitparams/SamplesOfUsageVerificationTest.java
+++ b/src/test/java/junitparams/SamplesOfUsageVerificationTest.java
@@ -15,8 +15,9 @@ public class SamplesOfUsageVerificationTest {
Result result = JUnitCore.runClasses(SamplesOfUsageTest.class);
assertEquals(0, result.getFailureCount());
- // TODO(JUnit4.10) - 2 tests are ignored because they do not work when run on the device.
- assertEquals(2, result.getIgnoreCount());
+ // Android-changed: 5 tests are ignored, see the @Ignore annotated methods in
+ // SamplesOfUsageTest for more details.
+ assertEquals(5, result.getIgnoreCount());
}
}
diff --git a/src/test/java/junitparams/internal/TestMethodTest.java b/src/test/java/junitparams/internal/TestMethodTest.java
index 2964781..62dc242 100644
--- a/src/test/java/junitparams/internal/TestMethodTest.java
+++ b/src/test/java/junitparams/internal/TestMethodTest.java
@@ -46,7 +46,7 @@ public class TestMethodTest {
public void flatTestMethodStructure() throws Exception {
System.setProperty("JUnitParams.flat", "true");
- Description description = plainTestMethod.describe();
+ Description description = plainTestMethod.describableFrameworkMethod().getDescription();
assertEquals("for_others_to_work(junitparams.internal.TestMethodTest)", description.getDisplayName());
assertTrue(description.getChildren().isEmpty());
@@ -54,20 +54,26 @@ public class TestMethodTest {
}
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
public void hierarchicalTestMethodStructure() throws Exception {
System.clearProperty("JUnitParams.flat");
- Description description = plainTestMethod.describe();
+ Description description = plainTestMethod.describableFrameworkMethod().getDescription();
assertEquals("forOthersToWork", description.getDisplayName());
assertEquals("[0] a (forOthersToWork)(junitparams.internal.TestMethodTest)", description.getChildren().get(0).getDisplayName());
assertEquals("[1] b (forOthersToWork)(junitparams.internal.TestMethodTest)", description.getChildren().get(1).getDisplayName());
}
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
public void hierarchicalArrayTestMethodStructure() throws Exception {
System.clearProperty("JUnitParams.flat");
- Description description = arrayTestMethod.describe();
+ Description description = arrayTestMethod.describableFrameworkMethod().getDescription();
assertEquals("forOthersToWorkWithArray", description.getDisplayName());
assertEquals("[0] a,b (forOthersToWorkWithArray)(junitparams.internal.TestMethodTest)",
diff --git a/src/test/java/junitparams/naming/MacroSubstitutionNamingStrategyTest.java b/src/test/java/junitparams/naming/MacroSubstitutionNamingStrategyTest.java
index b6c5c5c..418b946 100644
--- a/src/test/java/junitparams/naming/MacroSubstitutionNamingStrategyTest.java
+++ b/src/test/java/junitparams/naming/MacroSubstitutionNamingStrategyTest.java
@@ -3,6 +3,7 @@ package junitparams.naming;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.internal.TestMethod;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.FrameworkMethod;
@@ -30,6 +31,9 @@ public class MacroSubstitutionNamingStrategyTest {
new Object[]{"whenGivenMacroDoesntExist", "{not_existing_macro}"}};
}
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
@Parameters
public void testNaming(String methodName, String expectedTestCaseName) throws NoSuchMethodException {
diff --git a/src/test/java/junitparams/naming/NamingStrategyIsUsedByRunnerTest.java b/src/test/java/junitparams/naming/NamingStrategyIsUsedByRunnerTest.java
index 1e0ec24..effda7f 100644
--- a/src/test/java/junitparams/naming/NamingStrategyIsUsedByRunnerTest.java
+++ b/src/test/java/junitparams/naming/NamingStrategyIsUsedByRunnerTest.java
@@ -1,6 +1,7 @@
package junitparams.naming;
import org.junit.AfterClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.Request;
@@ -26,6 +27,9 @@ public class NamingStrategyIsUsedByRunnerTest {
"[1] Well formed name of sampleMethod with param2" + className);
}
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
@Parameters({"param1", "param2"})
@TestCaseName("[{index}] Well formed name of {method} with {params}")
diff --git a/src/test/java/junitparams/usage/SamplesOfUsageTest.java b/src/test/java/junitparams/usage/SamplesOfUsageTest.java
index 3c5f410..9a96961 100644
--- a/src/test/java/junitparams/usage/SamplesOfUsageTest.java
+++ b/src/test/java/junitparams/usage/SamplesOfUsageTest.java
@@ -102,12 +102,14 @@ public class SamplesOfUsageTest {
return new Object[]{new Object[]{"first", 1}, new Object[]{"second", 2}};
}
- @Ignore("does not work when run on device as it does not have access to the file")
+ // Android-changed: does not work when run on device as it does not have access to the file
+ @Ignore
@Test
@FileParameters("src/test/resources/test.csv")
public void loadParamsFromCsv(int age, String name) { }
- @Ignore("does not work when run on device as it does not have access to the file")
+ // Android-changed: does not work when run on device as it does not have access to the file
+ @Ignore
@Test
@FileParameters(value = "src/test/resources/test.csv", mapper = PersonMapper.class)
public void loadParamsFromAnyFile(PersonTest.Person person) { }
@@ -128,11 +130,17 @@ public class SamplesOfUsageTest {
@Parameters("please\\, escape commas if you use it here and don't want your parameters to be splitted")
public void commasInParametersUsage(String phrase) { }
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
@Parameters({ "1,1", "2,2", "3,6" })
@TestCaseName("factorial({0}) = {1}")
public void customNamesForTestCase(int argument, int result) { }
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
@Parameters({ "value1, value2", "value3, value4" })
@TestCaseName("[{index}] {method}: {params}")
@@ -148,6 +156,9 @@ public class SamplesOfUsageTest {
);
}
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
@Parameters(method = "mixedParameters")
@TestCaseName("{0}, {1}, {2}, {3}")
diff --git a/src/test/java/junitparams/usage/person_example/PersonTest.java b/src/test/java/junitparams/usage/person_example/PersonTest.java
index 927204e..b9f15c5 100644
--- a/src/test/java/junitparams/usage/person_example/PersonTest.java
+++ b/src/test/java/junitparams/usage/person_example/PersonTest.java
@@ -56,6 +56,9 @@ public class PersonTest {
}
}
+ // Android-changed: CTS and AndroidJUnitRunner rely on specific format to test names, changing
+ // them will prevent CTS and AndroidJUnitRunner from working properly; see b/36541809
+ @Ignore
@Test
@Parameters(method = "adultValues")
@TestCaseName("Is person with age {0} adult? It's {1} statement.")