如何在Scala中模拟静态函数(对象函数,而不是类函数) [英] How do I mock static function (Object function, not class function) in scala
本文介绍了如何在Scala中模拟静态函数(对象函数,而不是类函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Object A {
def a = { something}
}
// I've import A, but still have error message: not found: type A
val x = mock[A]
推荐答案
您可以找到此电子邮件线程具有指导意义。
You may find this email thread instructive.
虽然尚无法使用任何工具对对象进行纯粹的模拟,但是上面的线程确实为您提供了一些选择。所有这些都涉及在某种程度上更改您的设计。
Whilst pure mocking of the object is not possible with any tool yet, the thread above does have a few options for you. All of which involve changing your design to some degree.
这篇关于如何在Scala中模拟静态函数(对象函数,而不是类函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文