Exception with JunitParams running measurement tests on Android 19 and below

Description

I see an exception when using the JunitParams runner on Android 19 and below.

Playback Steps

  • Write a simple test suite and run on Android 19 or lower with the latest versions of Android testing support.

Code

The following test suite will reproduce the problem

@RunWith(JUnitParamsRunner.class) public class SimpleTest { @Test @Parameters({ "false", "true" }) public void simpleParameterizedTest(boolean enabled) { // Should execute and pass } } 

Expected Behavior

Tests must be performed and passed.

Actual behavior

Tests do not run because "no tests found"

Magazines

I checked the logs and I see the following exception.

 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 

Version

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' 
+5
source share
1 answer

We just fixed this issue in JUnitParams and released a new version.

Now you can download the latest version and start using it with Android 19 and below!

androidTestCompile 'pl.pragmatists:JUnitParams:1.1.1'

+1
source

Source: https://habr.com/ru/post/1271620/


All Articles