如果您已经进行了功能测试,是否需要进行单元和集成测试? [英] Do you need to do unit and integration testing if you already do functional testing?
问题描述
我公司的人们认为单元测试是很多额外的工作,与现有的功能测试相比,它提供的收益要少.单元测试和集成测试值得吗?请注意,现有的大型代码库在设计时就没有考虑到测试.
People at my company see unit testing as a lot of extra work, that offers fewer benefits than existing functional tests. Are unit and integration tests worth it? Note a large existing codebase that wasn't designed with testing in mind.
推荐答案
(我假设您使用的是功能测试",是指涉及整个系统或应用程序正在运行的测试.)
(I'm assuming that you're using "functional test" to mean a test involving the whole system or application being up and running.)
出于以下三个原因,我将对我编写的 new 功能进行单元测试:
I would unit test new functionality as I wrote it, for three reasons:
- 它可以帮助我更快地使用工作代码.通常,单元测试失败,修复代码,单元测试通过"的周转时间比功能测试失败,修复代码,功能测试通过"的时间短了 .
- 这可以帮助我以更简洁的方式设计代码
- 它可以帮助我理解我的代码以及维护代码的意图.如果我进行更改,它将使我更加自信自己没有损坏任何东西.
(这包括错误修复,如Epaga所建议.)
(This includes bug fixes, as suggested by Epaga.)
我强烈推荐迈克尔·费瑟斯(Michael Feathers)的有效地与传统一起工作代码" ,为您提供有关如何开始对不是针对其设计的代码库进行单元测试的提示.
I would strongly recommend Michael Feathers' "Working Effectively with Legacy Code" to give you tips on how to start unit testing a codebase which wasn't designed for it.
这篇关于如果您已经进行了功能测试,是否需要进行单元和集成测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!