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

Both ideas sound very similar to me, but there may be subtle differences or the same thing explained in different ways. What is the relationship between TDD and Test First Development / Programming?

+52
tdd testing
Dec 02 '08 at 17:33
source share
8 answers

There is a difference in that factor of movement.

Do you have a vague idea that a class (or a system - it can happen on different scales, of course) should look like, and then come up with tests that give it a real form? This is a TDD.

Do you know what the class’s public API is and just write tests before implementation? This test development.

My style tends to be a mixture of the two. Sometimes it’s obvious that there needs to be an API before writing any tests — in other cases, testability really drives the design.

In other words, TDD begins with "What questions do I want to ask?" whereas non-TDD (whether the test is first or not) begins with "What answer do I want to give?"

+60
Dec 02 '08 at 17:43
source share

Basically, these are different names that describe the same thing - well, in fact, five names, since the last D can act both for design and for development.

Test First was a term originally used, especially in the context of Extreme Programming, for a test refactor loop. The name Test Driven Development was proposed - and quickly adopted - later to emphasize the fact that TFD - and has always been - is more a design strategy than a testing strategy.

Obviously, today some people have different connotations for these two terms, but this was not the purpose of their existence, and I would not rely on the fact that this is well-known (because it is not). In fact, I would prefer the term TFD to be obsolete.

+24
Dec 02 '08 at 20:03
source share

There are many similar terms, such as test programming, test development, test development, or even test design. It is important to clarify a few points:

1. Test First Programming (TFP)

The term test programming is best programming practice. It was re-introduced (if not invented) by Kent Beck in his book Extreme Programming Explained: "Write unit tests before programming and continue with all the tests that you run at any time." So, when it comes to test programming, we are talking about writing automatic unit tests by the developer himself, who is going to write code to satisfy these tests. Unit tests accumulate and create a set of automatic regression tests that can be performed periodically.

2. Testing (TDD)

Testing Development (TDD) is the name of the methodology proposed by Kent Beck in his book Development Based on Testing by Example. This is a software development process, it is not just about writing tests before the code. The whole book is trying to explain it with patterns, workflows, culture, etc. One important aspect of this is the emphasis on refactoring.

Some people use the terms “test-first development”, test design or test programming and ... One thing is certain: a well-developed methodology is test-based development, and programming technology is test programming. The rest, as a rule, refer to the idea of ​​writing tests before the code or erroneously refer to test development or test programming.

+13
Jul 17 '13 at 18:13
source share

TDD = TFD + Refactoring.

When you do TFD, you apply some refactoring to make the code more versatile and reliable.

+10
Dec 02 '08 at 17:42
source share

Historically true: test programming and development through testing mean the same thing with an improved name

In the context of XP (Extreme Programming), which is a software development process that made popular programming and development through testing popular, programming was first renamed development through testing, and then through testing-based design, after realizing that Writing tests primarily has an extremely positive impact on software architecture and software system design.

This influence on architecture and design is the result of more or less surprising synonyms:

  • Testable
  • disconnected
  • reusable
  • Independently deployable
  • Independently developing
  • Whatever Reasonable

Software objects can be easily reused, tested, deployed independently, developed independently or easily justified separately if they are not related. Writing tests before the actual implementation is a practically bulletproof method that provides continuous decoupling.

This influence on the design and architecture of the software has become so important, among other positive effects, that the creators considered it appropriate to rename it from Test-First Programming to Test-Driven Development.

The name Test-Driven Development also helps to advance the method better in terms of acceptance and understanding, because the name Test-Driven Development focuses on the holistic aspects of the method than Test-First Programming.

Not historically correct, but useful

Although historically not correct, I find the following difference very useful:

Testing at the beginning of programming ...

... Any method in which tests for the test code are written before the test code.

Development through testing ...

... It is a specific subset of the "test first" programs that follows the three laws of development through testing, as described by Robert C. Martin:

  1. You cannot write production code until you write a failed unit test.
  2. You cannot write more unit tests than enough to fail, and compilation failed.
  3. You cannot write more production code than enough to pass the currently failed unit test. - Robert C. Martin, Three Laws of Test Driven Development

Following these three rules, you fall into the Red-Green-Refactor cycle. 1. You write a failed test. 2. You make it go through. 3. Now that it has passed, you can mercilessly refactor before writing the next failed test.

Please note that refactoring safely requires testing. Refactoring means changing the structure of the source code without changing the essential behavior. But how do we know that we did not accidentally change the essential behavior? What determines significant behavior? This is one of many things tests are useful for.

By the way, if your tests interfere with refactoring, your tests are too low-level, too closely related, and you may have used too much ridicule.

Other interesting renaming in Extreme Programming

  • Continuous Integration → Continuous Delivery → Continuous Deployment; Strictly speaking, they mean different things, however, in the spirit of XP, it meant “Continuous Deployment” from the very beginning, and when people jumped on the bandwagon, it became clear that the integration was taken too literally, and people stopped before they did it.
  • Continuous refactoring → Continuous design improvement; Refactoring is not a means to an end, but it has a higher goal.
  • 40 hours a week → Sustainable Pace (Urban legend: This renaming happened after the protests of French software developers.)
+6
Feb 19 '18 at 22:01
source share

This is exactly the same. First, both reference recording tests are performed, and then the code that passes the test is written

+1
Dec 02 '08 at 17:38
source share

TDD (Test Driven Development) is testing the first development / programming, although I saw and heard that TDD means creating constant, repeatable unit tests (even after the code), but in reality this means that the tests are written before the code they are being tested.

+1
Dec 02 '08 at 17:43
source share

In a development-driven test: as an example, the author, Kent Beck, clearly states that the "test first" (TF) rule is a rule. So TF is the principle that drives TDD. Later process.

0
Feb 02 '19 at 10:06
source share



All Articles