在 EasyMock Expect 调用上设置 Eclipse 断点的最佳方法是什么?
我有这样的代码,
ClockService mockClockService = createMock( ClockService.class );
Long timeFirstNodeCreated = new Date().getTime();
expect( mockClockService.getNow() ).andReturn( timeFirstNodeCreated ) ;
Long timeFirstNodeDeleted = new Date().getTime();
expect( mockClockService.getNow() ).andReturn( timeFirstNodeDeleted ) ;
我希望 Eclipse 在调用 mockClockService.getNow() 时随时挂起程序。但是,由于 ClockService 是一个接口,因此我无法在 ClockService.getNow() 上设置断点,并且由于 mockClockService 是 EasyMock 代理,因此我也无法在预期行上设置断点。
I have code like
ClockService mockClockService = createMock( ClockService.class );
Long timeFirstNodeCreated = new Date().getTime();
expect( mockClockService.getNow() ).andReturn( timeFirstNodeCreated ) ;
Long timeFirstNodeDeleted = new Date().getTime();
expect( mockClockService.getNow() ).andReturn( timeFirstNodeDeleted ) ;
I'd like Eclipse to suspend the program any time mockClockService.getNow() is called. However, since ClockService is an interface, I can't set a breakpoint on ClockService.getNow() and since mockClockService is an EasyMock proxy, I can't set a breakpoint on the expect lines either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您可以使用 andAnswer (或 andDelegateTo)方法来响应 getNow() 调用;您将编写 IAnswer(或 ClockService)的实现并在实现中设置断点。如:
应该可以。
但也许您想更多地说明为什么要这样做?这表明您可能存在设计问题......
I guess you could use the andAnswer (or andDelegateTo) method to respond to getNow() calls; you'd write an implementation of IAnswer (or ClockService) and set a breakpoint in your implementation. As in:
That ought to do it.
But maybe you want to say more about why you want to do this? It suggests that you might have a design problem...