I am seeing an exception when using the JunitParams runner on Android 19 and below.
The following test suite will reproduce the issue
@RunWith(JUnitParamsRunner.class)
public class SimpleTest {
@Test
@Parameters({ "false", "true" })
public void simpleParameterizedTest(boolean enabled) {
// Should execute and pass
}
}
Tests should execute and pass.
Tests are not run because "no tests are found"
I checked the logs and I see the following exception occurring.
09-07 12:17:01.187 3338-3355/com.twilio.video.test W/dalvikvm: Exception Ljava/util/regex/PatternSyntaxException; thrown while initializing Ljunitparams/naming/MacroSubstitutionNamingStrategy;
09-07 12:17:01.187 3338-3355/com.twilio.video.test E/TestExecutor: Fatal exception when running tests
java.lang.ExceptionInInitializerError
at junitparams.internal.TestMethod$1.computeValue(TestMethod.java:40)
at junitparams.internal.TestMethod$1.computeValue(TestMethod.java:35)
at junitparams.internal.Memoizer.get(Memoizer.java:11)
at junitparams.internal.TestMethod.describe(TestMethod.java:116)
at junitparams.internal.ParameterisedTestClassRunner.describeParameterisedMethod(ParameterisedTestClassRunner.java:161)
at junitparams.JUnitParamsRunner.describeMethod(JUnitParamsRunner.java:502)
at junitparams.internal.ParametrizedTestMethodsFilter.filteredMethods(ParametrizedTestMethodsFilter.java:30)
at junitparams.JUnitParamsRunner.getListOfMethods(JUnitParamsRunner.java:498)
at junitparams.JUnitParamsRunner.getDescription(JUnitParamsRunner.java:487)
at org.junit.runners.Suite.describeChild(Suite.java:123)
at org.junit.runners.Suite.describeChild(Suite.java:27)
at org.junit.runners.ParentRunner.shouldRun(ParentRunner.java:434)
at org.junit.runners.ParentRunner.filter(ParentRunner.java:382)
at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
at android.support.test.internal.runner.TestRequestBuilder$LenientFilterRequest.getRunner(TestRequestBuilder.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: java.util.regex.PatternSyntaxException: Look-behind pattern matches must have a bounded maximum length near index 40:
(?=\{[^\}]{0,50}\})|(?<=\{[^\}]{0,50}\})
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:411)
at java.util.regex.Pattern.<init>(Pattern.java:394)
at java.util.regex.Pattern.compile(Pattern.java:381)
at junitparams.naming.MacroSubstitutionNamingStrategy.<clinit>(MacroSubstitutionNamingStrategy.java:13)
... 19 more
Here is a snippet from my build.gradle
file.
androidTestCompile 'pl.pragmatists:JUnitParams:1.1.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test:rules:1.0.1'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
We've just fixed that issue in JUnitParams and released new version.
Now you can fetch the newest version and start using it with Android 19 and below!
androidTestCompile 'pl.pragmatists:JUnitParams:1.1.1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With