如何在此junit测试中使用模拟对象? 我需要在junit中实现模拟对象。 需要关于此代码的帮助。如何在此junit中使用模拟对象
public class TicketTest {
public static List<Ticket> tickList = new ArrayList<Ticket>();
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void objectValueSetting() throws Exception {
Ticket ticket = new Ticket();
ticket.setDescription("helllo");
ticket.setEmail("[email protected]");
tickList.add(ticket);
}
@Test
public void valueGetting() throws Exception {
Ticket ticket = tickList.get(0);
Assert.assertNotNull(ticket);
Assert.assertNotNull(ticket.getDescription());
Assert.assertNotNull(ticket.getEmail());
}
}
为什么你需要嘲笑任何东西?你想要测试什么?你的问题目前还不清楚。请阅读http://tinyurl.com/stack-hints –