Do you need to do unit and integration testing if

2020-06-05 05:54发布

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.

9条回答
贼婆χ
2楼-- · 2020-06-05 06:31

As it happens, I read a paper last night on this very subject. The authors compare projects within four groups at Microsoft and IBM, contrasting, in hindsight, projects which used both unit testing and functional testing and projects which used functional testing alone. To quote the authors:

"The results of the case studies indicate that the preview release defect density of the four products decreased between 40% and 90% relative to similar projects that did not use the TDD practice. Subjectively, the teams experienced a 15 to 35% increase in initial development time after adopting TDD."

This indicates that it is certainly worth doing unit testing when you add new functionality to your project.

查看更多
3楼-- · 2020-06-05 06:40

Yes they are worth it, I am now faster at coding since I started unit testing my code. I spend less time fixing bugs and more time thinking about what my code should do.

查看更多
Explosion°爆炸
4楼-- · 2020-06-05 06:41

You test when you want to know something about something. If you know that your product (system, unit, service, component...) is going to work, then there's no need to test it. If you're uncertain as to whether it will work, you probably have some questions about it. Whether those questions are worth answering is a matter of risk and priorities.

If you're sure that your product will work, and you don't have any questions about it, there is still one question that's worth asking: why don't I have any questions?

---Michael B.

查看更多
登录 后发表回答