集成测试实施
我有一个三层应用程序
- Web 应用程序(这里为简单起见,为 ASP.NET MVC)、
- 业务服务
- 数据存储库
我知道有四种类型的集成测试:
- 自上而下、
- 自下而上的
- 三明治(前两者的组合)
- 大爆炸
我知道我会像单元测试一样编写大爆炸测试,但没有任何模拟,所以我也会使用后端数据库...
问题
我不知道如何编写其他类型的集成测试?
- 如何编写非 bigbang 类型的集成测试?
- 集成测试是否应该等于单元测试,意味着相同数量的测试,但没有模拟的测试?或者这些测试应该测试完全不同的东西?
任何人都可以提供任何信息如何做到这一点(如果有的话)或者这样做是否实际上可行?
I have a three tiered app
- web app (asp.net mvc for simplicity here),
- business services
- data repositories
And I know there are four types of integration tests:
- top down
- bottom up
- sandwich (combination of the top two)
- big bang
I know I would write big-bang tests just like unit tests but without any mocking so I would employ a backend DB as well...
Questions
I don't know how to write other types of integration tests?
- How do I write non-bigbang types of integration tests?
- Should integration tests be equal to unit tests meaning same number of tests, but testing without mocks? Or should these tests test something completely different?
Could anybody provide any information how to do this (if at all) or whether it's actually feasible doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议这样做:
根据您的系统,您可能想也不想在代码顶层补充 3 的集成测试,但不涉及 UI。无论您选择哪种选择,请确保通过单位和医疗机构获得更全面的覆盖。集中的集成测试,因为在顶层测试各种行为具有一定的复杂性,可能很快就会失控。
正如我在 1 和 1 中提到的2、当那些测试不同的东西时最好。这取决于系统,但我通常期望单元测试的数量是集成测试数量的几倍。对于完整的系统测试,请确保您有足够的资源,以便您可以判断所有部分都已正确连接,但又不能太多,以免变得太复杂而无法测试每个场景。
I suggest doing these:
Depending on your system, you may or not want to complement 3 with integration tests at the top level of the code, but without involving the UI. Regardless of which option you take, make sure to have more comprehensive coverage through unit & focused integration tests, as testing various behavior at the top level have a complexity level that can get out of control very quickly.
As I mentioned in 1 & 2, its best when those test different things. This depends on the system, but I'd usually expect the amount of unit tests to be a few times the amount of integration tests. For full system tests, make sure you have enough so that you can tell all the pieces were hooked correctly, but not so much that it becomes too complex to test each scenario.