我该如何嘲笑Person?
class Test {
private Person person;
...
public void testMethod() {
person.someMethod();
...
}
}
答案 0 :(得分:1)
使用注释和Person
模拟mockito
的一种方法:
public class UnitTest {
@Mock
private Person person;
@InjectMocks
private Test test = new Test();
@Test
public void testMethod() {
MockitoAnnotations.initMocks(this);
test.testMethod();
}
}