在升级到JunitParams 1.0.6之后,我有使用JunitParams 1.0.5运行良好的测试,然后得到了initializationError。任何人都可以帮忙吗?
硒:3.3.1 JunitParams:1.0.6 Firefox:52ESR
堆栈追踪:
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)
答案 0 :(得分:1)
这是JUnit版本兼容性问题。有关类似案例,请参阅https://github.com/Pragmatists/JUnitParams/issues/102。
JUnitParams 1.0.6需要JUnit 4.12。确保您没有在项目中覆盖此版本。如果类路径上有JUnit 4.10或更早版本,则BlockJUnit4ClassRunner.validateFields
方法具有private
访问修饰符。调用它的代码期望它是protected
,这是JUnit 4.11+的情况。使用较旧的JUnit版本,您会收到您发布的错误。