[TDD] 为什么要测一点,改一点;改一点,测一点

为什么不多改一些代码再测?这样效率不会更高吗?

因为代码写多了再测,就会遗漏一些测试点。比如说测试一个“圆”,你只能在圆孤上选择测试点;而这个圆其实是由两个半圆组成的(就像今天的日偏食),你本来还应该分别测试这两个半圆的边!

那我们的测试粒度倒底要小到什么地步?Kent Beck说,看感觉。他用一句很口语化的话来概括:"Are the teeny-tiny steps feeling restrictive? Take bigger steps; Are you feeling a little unsure? Take Smaller steps".

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.