Powemock无法模拟没有存在其依赖类的类。

huangapple go评论64阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年5月29日 14:22:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/62079841.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定