java - Unable to run JUnit test with PowerMockRunner -
i have gradle based java project want mock private method using powermock. problem not able utilize powermockrunner next exception when add together @runwith(org.powermock.modules.junit4.powermockrunner.class)
annotation.
error:
org.powermock.reflect.exceptions.fieldnotfoundexception: field 'ftestclass' not found in class org.junit.internal.runners.methodvalidator. @ org.powermock.reflect.internal.whiteboximpl.getinternalstate(whiteboximpl.java:581) @ org.powermock.reflect.whitebox.getinternalstate(whitebox.java:308) @ org.powermock.modules.junit4.internal.impl.testcaseworkaround.powermockjunit4methodvalidator.validate testmethods(powermockjunit4methodvalidator.java:79) @ org.powermock.modules.junit4.internal.impl.testcaseworkaround.powermockjunit4methodvalidator.validate instancemethods(powermockjunit4methodvalidator.java:49) @ org.junit.internal.runners.methodvalidator.validatemethodsfordefaultrunner(methodvalidator.java:51) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl.validate(powermockjunit44runnerdelegateimpl.java:108) ...
this test dependencies:
testcompile 'junit:junit:4.+', 'org.powermock:powermock-core:1.5.6', 'org.powermock:powermock-module-junit4:1.5.6', 'org.powermock:powermock-api-mockito:1.5.6'
the test fails when empty (initialization error):
@runwith(powermockrunner.class) public class sometest { @test public void testsomething() { } }
any ideas might wrong? other tests using powermock working fine (none of them uses powermockrunner).
greetings , help! ben
this bug occurs when utilize junit 4.12 , powermock < 1.6.1. problem solved in powermock 1.6.1. please update dependencies accordingly
testcompile 'junit:junit:4.12', 'org.powermock:powermock-core:1.6.1', 'org.powermock:powermock-module-junit4:1.6.1', 'org.powermock:powermock-api-mockito:1.6.1'
if cannot upgrade powermock can utilize junit 4.11.
testcompile 'junit:junit:4.11', 'org.powermock:powermock-core:1.5.6', 'org.powermock:powermock-module-junit4:1.5.6', 'org.powermock:powermock-api-mockito:1.5.6'
could please add together farther lines of stacktrace, uncover more details problem.
java exception junit powermock
No comments:
Post a Comment