【发布时间】:2018-12-05 15:22:59
【问题描述】:
我将如何模拟 Person?
class Test {
private Person person;
...
public void testMethod() {
person.someMethod();
...
}
}
【问题讨论】:
标签: unit-testing testing junit mockito powermockito
我将如何模拟 Person?
class Test {
private Person person;
...
public void testMethod() {
person.someMethod();
...
}
}
【问题讨论】:
标签: unit-testing testing junit mockito powermockito
一种模拟Person的方法,使用注解和mockito:
public class UnitTest {
@Mock
private Person person;
@InjectMocks
private Test test = new Test();
@Test
public void testMethod() {
MockitoAnnotations.initMocks(this);
test.testMethod();
}
}
【讨论】: