Is there a difference between TDD and Test First Development (or Test First Programming)?

前端 未结 8 1449
鱼传尺愫
鱼传尺愫 2021-02-01 00:41

Both ideas sound very similar to me, but there might be subtle differences or the exact same thing, explained in different ways. What is the relationship between TDD and Test Fi

8条回答
  •  长情又很酷
    2021-02-01 01:25

    There's a difference in terms of what the driving factor is.

    Do you have a vague idea of what the class (or system - this can happen at different scales, of course) should look like, then think up tests which give it the actual shape? That's TDD.

    Do you know exactly what the public API of the class should be, and just write the tests before the implementation? That's test-first development.

    My style tends to be a mixture of the two. Sometimes it's obvious what the API should be before writing any tests - in other cases testability really drives the design.

    To put it another way, TDD starts with "What questions do I want to ask?" whereas non-TDD (whether test first or not) starts with "What answer do I want to give?"

提交回复
热议问题