I have tests which have been running fine with JunitParams 1.0.5, after I upgraded to JunitParams 1.0.6, then got initializationError. Can anyone help with this?
Selenium: 3.3.1 JunitParams: 1.0.6 Firefox: 52ESR
Stack trace:
java.lang.IllegalAccessError: tried to access method org.junit.runners.BlockJUnit4ClassRunner.validateFields(Ljava/util/List;)V from class junitparams.JUnitParamsRunner
at junitparams.JUnitParamsRunner.collectInitializationErrors(JUnitParamsRunner.java:405)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:336)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:56)
at junitparams.JUnitParamsRunner.<init>(JUnitParamsRunner.java:393)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
This is a JUnit version compatibility issue. See https://github.com/Pragmatists/JUnitParams/issues/102 for a similar case.
JUnitParams 1.0.6 requires JUnit 4.12. Make sure you are not overriding this version in your project. If you have JUnit 4.10 or older on your classpath, the BlockJUnit4ClassRunner.validateFields
method has private
access modifier. The code that calls it expects it to be protected
which is the case for JUnit 4.11+. With older JUnit versions you get the error that you posted.