File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes PowerMock Test mechanism error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "PowerMock Test mechanism error" Watch "PowerMock Test mechanism error" New topic
Author

PowerMock Test mechanism error

saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
i am a newbie of power mock, i am actually facing a few set of issues when i included power mock into my application.
I am using mockito(mockito-all-1.8.5.jar) and i included the compitable version of power mock for this(powermock-mockito-1.4.9-full and its dependencies) when i run the test mocking a static class and individually running the test through eclipse IDE the test are running fine and as expected.

But when i run cumulatively all the tests by using ant i am facing an error
If you can observe the errors are being showed as test case which i h've not included in my test suit
Test mechanism Error java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
the trace is
[junit] Testcase: Test mechanism: Caused an ERROR
[junit] java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
[junit] java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
[junit] at org.powermock.api.support.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:52)
[junit] at org.powermock.api.support.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:26)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator$MockitoStateCleaner.clearThreadLocalIn(MockCreator.java:157)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator$MockitoStateCleaner.clearMockProgress(MockCreator.java:148)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator$MockitoStateCleaner.run(MockCreator.java:143)
[junit] at org.powermock.core.MockRepository.clear(MockRepository.java:121)
[junit] at org.powermock.reflect.internal.WhiteboxImpl.performMethodInvocation(WhiteboxImpl.java:2014)
[junit] at org.powermock.reflect.internal.WhiteboxImpl.doInvokeMethod(WhiteboxImpl.java:885)
[junit] at org.powermock.reflect.internal.WhiteboxImpl.invokeMethod(WhiteboxImpl.java:859)
[junit] at org.powermock.reflect.Whitebox.invokeMethod(Whitebox.java:466)
[junit] at org.powermock.modules.junit4.common.internal.impl.PowerMockJUnit4RunListener.testFinished(PowerMockJUnit4RunListener.java:55)
[junit] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
[junit] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
[junit] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
[junit] at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:118)
[junit] at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:102)
[junit] at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
[junit] at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[junit] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
[junit] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
[junit] Caused by: java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:247)
[junit] at org.powermock.api.support.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:50)

the above error is only for the first test suit(power mock uesd in this) which the compiler comes across, but runs all the test cases in that suit as expected. The remaining test suits with power mock used are not getting any test being run but facing the following error.
initializationError Error java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
the trace is
[junit] Testcase: initializationError(com.cscinfo.pb.web.action.myDocuments.UploadMatterDocumentActionTest): Caused an ERROR
[junit] java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
[junit] java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
[junit] at org.powermock.api.support.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:52)
[junit] at org.powermock.api.support.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:26)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator$MockitoStateCleaner.clearThreadLocalIn(MockCreator.java:157)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator$MockitoStateCleaner.clearMockProgress(MockCreator.java:148)
[junit] at org.powermock.api.mockito.internal.mockcreation.MockCreator$MockitoStateCleaner.run(MockCreator.java:143)
[junit] at org.powermock.core.MockRepository.clear(MockRepository.java:121)
[junit] at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:42)
[junit] at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:26)
[junit] at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
[junit] at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
[junit] at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[junit] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
[junit] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
[junit] Caused by: java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:247)
[junit] at org.powermock.api.support.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:50)

sam backet
Greenhorn

Joined: Sep 02, 2011
Posts: 22

I need your code to solve your problem

Thanks
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
thanks for your reply but i have resolved it myself, it is due to other jar conflicts, the app basically a web app so there were other jars which led to those errors.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PowerMock Test mechanism error