集成测试——“不抛出异常”方法。有道理吗?
有时,集成测试编写起来相当复杂,或者开发人员没有足够的时间来检查输出 - 编写仅确保“不抛出异常”的测试是否有意义?此类测试提供了一些输入参数集,并且不检查结果,而只是确保代码不会因异常而失败?
此类测试可能不是很有用,但适合您没有时间的情况?
Sometimes integration tests are rather complex to write or developers have no enough time to check output - does it make sense to write tests that make sure "no exceptions are thrown" only? Such tests provide some input parameters set(s) and doesn't check the result, but only make sure code not failed with exception?
May be such tests are not very useful but appropriate in situations when you have no time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
集成测试基本上与单元测试相同,尽管由于大量的额外组件而更复杂、更复杂。单元测试都是关于提供一些输入并断言一些结果(无论是值还是异常等)。这同样适用于您的集成测试。在最坏的情况下,至少测试一下实际结果是否有意义,而不是仅仅假设没有例外就意味着没问题。这种假设是极其糟糕的做法,并且带有懒惰的味道,或者可能缺乏对方法的思考。
An integration test is basically the same as a unit test albeit more complex more involving due to the significant extra components. Unit tests are all about providing some inputs and asserting some results be they values or exceptions etc. The same should be applied to your integration tests. At worst at least test that the actual outcome makes sense instead of just assuming no exceptions means its ok. Such an assumption is extremely poor practice and smells of laziness or perhaps lack of thought about the approach.