Tomas
Tomas

Reputation: 21

Mockito cannot find defined class while running a test

I am having trouble with mockito dependencies.I wrote a sample test and when I ran it I got this exception

java.lang.NoClassDefFoundError: javassist/NotFoundException
    at org.powermock.core.transformers.TestClassTransformerBuilder$RemovesTestMethodAnnotation.fromMethods(TestClassTransformerBuilder.java:62)
    at org.powermock.tests.utils.impl.AbstractCommonTestSuiteChunkerImpl.createDefaultMockLoader(AbstractCommonTestSuiteChunkerImpl.java:126)
....

the full Exception can be viewed at : https://pastebin.com/xWqUX0Wc and the test code - https://pastebin.com/pbWLc27B

My dependencies are the following:

mockito-all-1.9.5.jar
powermock-api-mockito-1.6.3.jar
powermock-api-support-1.4.9.jar
powermock-core-2.0.4.jar
powermock-module-junit-1.7.4.jar
powermock-module-junit-common-1.7.4.jar
powermock-reflect-2.0.4.jar
powermock-test-utils-1.5.3.jar

Where can be the problem?I guess something is wrong with the version of the jars.What version of the jars would you suggest to use ?

Upvotes: 2

Views: 582

Answers (1)

Iftikhar Hussain
Iftikhar Hussain

Reputation: 281

Your are missing JavaAssist jar download below jars and add them into your projects or add them in maven pom.xml file.

<javaassist.version>3.20.0-GA</javaassist.version>
         <dependency>
             <groupId>org.javassist</groupId>
             <artifactId>javassist</artifactId>
             <version>${javaassist.version}</version>
             <scope>compile</scope>
         </dependency>

Upvotes: 2

Related Questions