【发布时间】:2021-10-29 13:16:47
【问题描述】:
我有一个类使用另一个类。
Class A {
public B b;
A(){
b = new B()
}
fun methodA(){
method1()
}
}
Class B {
String name
public void method1(){
someMethod()
}
public void someMethod(){
Log.d("this method gets called")
}
}
A a = new A()
B b = spy(a.b)
doNothing.when(b).somethod()
a.methodA() // This still calls someMethod()
doNothing 在 Hierachy 中不起作用。谁能帮忙。
【问题讨论】:
-
您可以做一些事情来让这个示例更容易理解:1. 格式化您的代码 2. 删除拼写错误。 3. 使用一种编程语言
标签: android unit-testing mockito