How to use Mockito with Junit in liferay?

Jamie Sammons, modified 2 Years ago. New Member Posts: 5 Join Date: 12/9/20 Recent Posts

Hello,

I am writing unit test cases.

Here is the dependency that I have configured

testCompile group: "junit", name: "junit", version: "4.12"

testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.0.0-beta'

testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.9'

testCompile group: 'org.powermock', name: 'powermock-module-junit4-rule', version: '2.0.9'

testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'

testCompile group: 'org.powermock', name: 'powermock-classloading-xstream', version: '1.6.6'

when I do Mockito.mock(SomeClass.class); I am getting the below error when I do gradlew.bat test

java.lang.NoClassDefFoundError: Could not initialize class org.mockito.Mockito


I have tried almost all versions of dependencies, but it is showing the same

Here are the basic details of the project configurations

Java version: Oracle 11

Gradle version: 6.6.1

Liferay: dxp-7.4-u50

Looking for urgent support on this.

Thanks in advance