Moving over to mockito 2 - ClassCastException occurred while creating the mockito mock

793 views
Skip to first unread message

mikael petterson

unread,
Jun 8, 2018, 6:17:44 AM6/8/18
to mockito
Hi,

I am using  the following versions.

  <mockito.version>2.9.0</mockito.version>
   <powermock.version>1.7.1</powermock.version>


and got the following error:


ClassCastException occurred while creating the mockito mock :
  class to mock : 'org.testng.ITestNGMethod', loaded by classloader : 'sun.misc.Launcher$AppClassLoader@6bc7c054'
  created class : 'org.testng.ITestNGMethod$MockitoMock$1502536221', loaded by classloader : 'net.bytebuddy.dynamic.loading.MultipleParentClassLoader@55e5d447'
  proxy instance class : 'org.testng.ITestNGMethod$MockitoMock$1502536221', loaded by classloader : 'net.bytebuddy.dynamic.loading.MultipleParentClassLoader@55e5d447'
  instance creation by : ObjenesisInstantiator

You might experience classloading issues, please ask the mockito mailing-list.

    at com.company.feature.FeatureHelperTest.setup(FeatureHelperTest.java:75)
Caused by: java.lang.ClassCastException: org.testng.ITestNGMethod$MockitoMock$1502536221 cannot be cast to org.mockito.internal.creation.bytebuddy.MockAccess
    at com.company.feature.FeatureHelperTest.setup(FeatureHelperTest.java:75)

This is the code that fails:

   ITestNGMethod method = Mockito.mock(ITestNGMethod.class);


Any ideas?

//mike



sajal aggarwal

unread,
Aug 13, 2018, 5:37:50 AM8/13/18
to mockito
Were you able to solve this?
I am getting the same error?
Reply all
Reply to author
Forward
0 new messages