看到一点关于TDD(Test Driven Development)的精辟论述,原文如下:
Actually,writing unit test makes you think (or,design). For example,with TDD method,you can hardly write tight-coupled code,because it's difficult to write test for them. That's why I always say that TDD does not slow down your development. Without TDD,do you spend all the time on coding? Absolutely no. Still lots of time spent on thinking and designing,however you don't have an approach to record the result of thinking. TDD is something makes you think accurately,and record the result,and prove it again and again.
(实际上,做单元测试会促使你去思考或去设计.例如,使用TDD方法,你几乎不能去写一个高聚合的代码,因为去为他们写测试是很困难的事情.这就是为什么我们常常说的,TDD不会减慢你的开发速度.如果没有TDD,你会把你的全部时间都花费在写代码上吗???绝对是不可能的,你仍然会有许多时间在思考,在设计,然而,你却没有一个方法去记录你思考的结果.TDD是一个使你精准的去思考,并且可以一遍一遍的去证明你思考的结果的好东东....)
我们要测试先行!
原文链接:https://www.f2er.com/javaschema/288302.html