1

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)
Jingjing
  • 13
  • 1
  • 5
  • That looks like a JUnitParams bug. Have you checked their github issues? Looks like a few similar problems there: https://github.com/Pragmatists/JUnitParams/issues – Mark Lapierre Mar 15 '17 at 05:56
  • Thanks Mark. It works now after I updated to JUnit 4.12. I also updated the question to avoid confusion. – Jingjing Mar 15 '17 at 19:06

1 Answers1

1

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.

Adam Michalik
  • 9,678
  • 13
  • 71
  • 102
  • Thanks for the help. You are right, the parent project is overriding with an older version. It works now after I updated to JUnit 4.12. – Jingjing Mar 15 '17 at 18:58
  • @Jingjing Glad to help. If this solved your problem, you can mark the answer as accepted using the big tick to the left. – Adam Michalik Mar 16 '17 at 08:11