Open wgslucky opened 6 years ago
Have you found a solution for this?
any solution to this?
Got the same problem. Any solution or workaround would be appreciated
same problem, cast exception was caused by below sentence:
try {
String classOrAlias = new PluginFinder(pluginSwitch).findPluginClass(Iterables.toIterable(resources));
if (classOrAlias != null) {
if (classOrAlias.equals(alias)) {
classOrAlias = plugins.getDefaultPluginClass(alias);
}
Class<?> pluginClass = loader.loadClass(classOrAlias);
Object plugin = pluginClass.newInstance();
return service.cast(plugin);
}
return null;
} catch (Exception e) {
throw new IllegalStateException(
"Failed to load " + service + " implementation declared in " + resources, e);
}
service.getClassLoader().nameAndId
is org.powermock.core.classloader.javassist.JavassistMockClassLoader @7aead157
pluginClass.getClassLoader().name
is app
I added org.mockito.*
into @PowerMockIgnore.value
, it fixed.
I added org.mockito.* into @PowerMockIgnore.value, it fixed.
what did this mean? who can explain this?
I added org.mockito.* into @PowerMockIgnore.value, it fixed.
what did this mean? who can explain this?
there are two classloaders, and the class of service was loaded by JavassistMockClassLoader but plugin class was loaded by AppClassloader, so type cast failed. you have to make them loaded by the same one classloader.
I added org.mockito.* into @PowerMockIgnore.value, it fixed.
what did this mean? who can explain this?
there are two classloaders, and the class of service was loaded by JavassistMockClassLoader but plugin class was loaded by AppClassloader, so type cast failed. you have to make them loaded by the same one classloader.
Thanks,I got what you just explained, but can not understand this one: I added org.mockito.* into @PowerMockIgnore.value, it fixed.
Finally, I think I have got it, you mean adding @PowerMockIgnore("org.mockito.*")
on the test class , right?
My powermock and test dependency in pom.xml is :
when I use suite.xml to test group by testng and powermockito,if I add @PrepareForTest on test claas,and will throw this exception: