'JUnit issue while using Mockito

I have created multiple junit test cases with mocking the Cassandra CQLSession class using Mockito framework. When I run the individual test class the it works. but when i run the test suite as a whole, seeing below error for mockito java.lang.NoClassDefFoundError: Could not initialize class com.datastax.oss.driver.api.core.CqlSession$MockitoMock$534112137 at jdk.internal.reflect.GeneratedSerializationConstructorAccessor5.newInstance(Unknown Source) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:48) at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73) at org.mockito.internal.creation.instance.ObjenesisInstantiator.newInstance(ObjenesisInstantiator.java:21) at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.doCreateMock(InlineByteBuddyMockMaker.java:360) at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.createMock(InlineByteBuddyMockMaker.java:318) at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:53) at org.mockito.internal.MockitoCore.mock(MockitoCore.java:61) at org.mockito.Mockito.mock(Mockito.java:1949)

Version details:

testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.8.0'
testImplementation group: 'junit', name: 'junit', version: '4.13'

also tried with mockito version 4.0, still same error. pls let me know is there anything I missed.



Solution 1:[1]

Just incase some one facing the similar issue, issue resolved after the restart of eclipse .

Solution 2:[2]

I faced similar issue in my spring boot project. Upgrading Springboot starter parent from 2.6.7 to 2.7.0 fixed the issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PraveenKumar K G
Solution 2 Sai Kumar