我创建了一个影子类,它按照http://robolectric.org/extending中的描述调用真实对象
@Implements(View::class)
class MyShadowView {
@RealObject
private lateinit var realView: View
@Implementation
fun animate(): ViewPropertyAnimator {
return realView.animate() // this call ends up calling my shadow's animate() function recursively
}
}然而,当我的影子方法被执行时,它会导致无限的递归。
我做错了什么?
(我使用的是Robolectric 4.2。)
发布于 2020-05-29 15:36:23
根据http://robolectric.org/javadoc/4.1/org/robolectric/shadow/api/Shadow.html的说法,应该是这样的:
@Implementation
fun animate(): ViewPropertyAnimator {
Shadow.directlyOn(realView, View::class.java).animate()
}https://stackoverflow.com/questions/56572144
复制相似问题