Skip to content Skip to sidebar Skip to footer

Android + Powermock + Mockito + Maven Build Error With Classnotfoundexception

I´m facing a strange build problem with powermock and mockito using maven. I can perfectly run the tests wihtin ecplise (wihtout using maven). But when i try to run the test with

Solution 1:

You need to add Dexmaker to your dependencies like this :

<dependency><groupId>org.mockito</groupId><artifactId>mockito-all</artifactId><version>1.9.5</version></dependency><dependency><groupId>com.google.dexmaker</groupId><artifactId>dexmaker</artifactId><version>1.0</version></dependency><dependency><groupId>com.google.dexmaker</groupId><artifactId>dexmaker-mockito</artifactId><version>1.0</version></dependency>

However, I think it not works with Powermock. This post can help you.

Solution 2:

Your maven configuration looks correct, besides org.mockito.internal.progress.ThreadSafeMockingProgress, shouldn't be missing.

Which mockito version are you seeing when doing the following command ?

mvn dependency:build-classpath -DincludeScope=test

Solution 3:

Just in case this randomly helps someone, I got past the same error by commenting out a Surefire plugin configuration.

I had the same error, analysed Eclipse/Maven classpaths, found no difference (apart from "/eclipse/configuration/org.eclipse.osgi/bundles/320/1/.cp/" entries).

In my case, I had previously disabled test forking for the Surefire plugin in the POM (to troubleshoot a different issue). I thought I'd just try commenting that out and that got it working again. Random, but I thought I'd pass it on.

For completeness, the configuration I commented out was as follows:

<!--
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.7.2</version><configuration><forkMode>never</forkMode></configuration></plugin>
-->

Post a Comment for "Android + Powermock + Mockito + Maven Build Error With Classnotfoundexception"