英文:
Powemock unable to mock class whose dependent class is not present
问题
我正在使用第三方的JAR文件,其中包含一个名为A的类。A类依赖于B类,但是这个B类在JAR文件中不存在。
我试图对A类进行模拟,但是对于类B却出现了"NoClassDefFoundError"错误。
在这种情况下是否可能对类A进行模拟?如果可以的话,您能否提供一种方法?
英文:
I am using the third party jar file which contains a class A. Class A is depends on the class B but this B class is not present in the jar file.
I am trying to mock the Class A but getting "NoClassDefFoundError" for the class B.
Is it possible to mock class A here? If yes could you please suggest a way to do it?
答案1
得分: 1
自从你不会使用 A 或 B(你将会模拟它们),尝试为他提供一个假的 B 类。显然,你需要使用与原始 B 相同的包名称。
英文:
Since you wont be using A or B (you will be mocking them) try to feed him a fake class B. Obviously you need to use the same package name as the original B.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论