设置方法调用的期望,同时仍然调用原始实现
It appears as though setting any method-call expectation with Mocha prevent the original implementation from being called.
This seems to cover calling the original method with rspec.
Is there a way to do this with Mocha? Or does anyone know why this wouldn't be supported?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于几个原因这是不可能的。原因之一是测试方法的副作用和测试方法的调用可以在两个单独的测试中更清楚地完成。我读到的另一个原因是,在纯粹的单元测试中,您不会对另一种方法的副作用做出断言。您将测试调用,然后在该特定方法的单元测试中测试被调用方法的副作用。
This is not possible for a couple reasons. One reason is that testing the side effect of a method and testing the invocation of a method can be done more clearly in two separate tests. Another reason I've read is that in purist unit testing, you wouldn't make an assertion about another method's side effect. You would test the invocation and then test the called methods side effects in unit tests for that specific method.