java - Why does PowerMock try to load some classes, which are used in non-mocking class method? -
i use junit4 mockito unit testing, , i'm trying add powermock toolbox. , @ once i'm facing weird class loading behaviour of powermock. so, use code that:
@preparefortest(classtomock.class) public class mytest { @rule public powermockrule rule = new powermockrule(); @test public void mytest() throws exception { // test code using classtomock myhelper.staticmethod(param); // other test code } }
myhelper class bundle, , staticmethod() method, don't need mocked. method uses google gson , serializers (let's - myserializer class). , powermock throws me javassist.notfoundexception google gson , myserializer. example:
caused by: javassist.notfoundexception: com.google.gson.gsonbuilder @ javassist.classpool.get(classpool.java:450) @ org.powermock.core.classloader.mockclassloader.loadunmockedclass(mockclassloader.java:220)
i can add classes classpath (to impored-packages), don't want to. , why powermock try load classes, used inside method, supposed "black box", @ first place?
can explain that, please?
also, can rid of loading gson using @powermockignore("com.google.*") annotation, doesn't work myserializer. , doesn't seem proper solution anyway.
thanks!
your classes might using
static blocks
which needs suppressed using powermock, not go , load required classes static blocks
Comments
Post a Comment