1

在我升级到 JunitParams 1.0.6 后,我的测试在 JunitParams 1.0.5 上运行良好,然后得到了初始化错误。有人能帮忙吗?

硒:3.3.1 JunitParams:1.0.6 火狐: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)
4

1 回答 1

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 版本,您会收到您发布的错误。

于 2017-03-15T11:28:39.893 回答