java - Junit: MethodNotFoundException with PowerMock -
while running dbunit based junit test case, following exception:
java.lang.runtimeexception: invoking beforetestmethod method on powermock test listener org.powermock.api.extension.listener.annotationenabler@2a5f1994 failed. @ org.powermock.tests.utils.impl.powermocktestnotifierimpl.notifybeforetestmethod(powermocktestnotifierimpl.java:92) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl$powermockjunit44methodrunner.executetest(powermockjunit44runnerdelegateimpl.java:292) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl$powermockjunit44methodrunner.runbeforesthentestthenafters(powermockjunit44runnerdelegateimpl.java:282) @ org.junit.internal.runners.methodroadie.runtest(methodroadie.java:84) @ org.junit.internal.runners.methodroadie.run(methodroadie.java:49) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl.invoketestmethod(powermockjunit44runnerdelegateimpl.java:207) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl.runmethods(powermockjunit44runnerdelegateimpl.java:146) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl$1.run(powermockjunit44runnerdelegateimpl.java:120) @ org.junit.internal.runners.classroadie.rununprotected(classroadie.java:34) @ org.junit.internal.runners.classroadie.runprotected(classroadie.java:44) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl.run(powermockjunit44runnerdelegateimpl.java:118) @ org.powermock.modules.junit4.common.internal.impl.junit4testsuitechunkerimpl.run(junit4testsuitechunkerimpl.java:102) @ org.powermock.modules.junit4.common.internal.impl.abstractcommonpowermockrunner.run(abstractcommonpowermockrunner.java:53) @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:50) @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:467) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:683) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:390) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:197) caused by: org.powermock.reflect.exceptions.methodnotfoundexception: no method found name 'assertnoannotations' parameter types: [ java.lang.reflect.field, [ljava.lang.class; ] in class org.powermock.api.mockito.internal.configuration.powermockitoinjectingannotationengine. @ org.powermock.reflect.internal.whiteboximpl.throwexceptionifmethodwasnotfound(whiteboximpl.java:1247) @ org.powermock.reflect.internal.whiteboximpl.findmethodorthrowexception(whiteboximpl.java:985) @ org.powermock.reflect.internal.whiteboximpl.doinvokemethod(whiteboximpl.java:882) @ org.powermock.reflect.internal.whiteboximpl.invokemethod(whiteboximpl.java:713) @ org.powermock.reflect.whitebox.invokemethod(whitebox.java:401) @ org.powermock.api.mockito.internal.configuration.powermockitoinjectingannotationengine.process(powermockitoinjectingannotationengine.java:45) @ org.powermock.api.extension.listener.annotationenabler.injectspiesandinjecttosetters(annotationenabler.java:55) @ org.powermock.api.extension.listener.annotationenabler.beforetestmethod(annotationenabler.java:50) @ org.powermock.tests.utils.impl.powermocktestnotifierimpl.notifybeforetestmethod(powermocktestnotifierimpl.java:90) ... 18 more
my class looks like:
@runwith(powermockrunner.class) public class sampledbtest extends { /** service mock */ @injectmocks private testservice testservice; /** entity manager. */ entitymanager entitymanager; /** * sets up. * * @throws exception exception */ @before public final void setup() throws exception { // entity manager injectfield(testservice, "entitymanager", entitymanager); } .... ....
here testservice stateless session bean interface. not able find explanation anywhere weird exception. please let me know, if have idea.
thanks.
i think use incompatible versions of powermock , mockito.
if @ stacktrack, see, exception thrown powermockitoinjectingannotationengine
, class can't find assertnoannotations
method.
last version of powermock 1.5.6. so, @ src of class older version of powermock (1.4.12, example) , see, there invoke of assertnoannotations
method processed. starting 1.5 version, class don't use such invoke.
last version of mockito 1.9.5. now, if @ src of injectingannotationengine
( extended powermockitoinjectingannotationengine
) 1.9.0 version of mockito, see, there assertnoannotations
method persist. and, in 1.9.5 version - method gone.
i think, rid of error updating versions of frameworks use.
Comments
Post a Comment