Test-Driven Development vs Test-After Developer

Test-Driven Development vs Test-After Developer

From the perspective of someone who practices Test-Driven Development, this gets things backwards. I believe that it

Test-Driven Development vs Test-After DeveloperFrom the perspective of someone who practices Test-Driven Development (TDD), this gets things backwards. I believe that it is an essential part of TDD that you must write your unit test before writing any application code. Why does it matter?

Test-Driven Development is first and foremost an application design methodology. If you write your unit tests after you write your application code, then you are not driving the design of your application with your unit tests. In other words, Test-After Development ignores the Driven in Test-Driven Development.

Let’s consider a concrete scenario… Here are the steps that I would follow using Test-Driven Development:

  1. Write a list of user stories that describe what the application should do. These user stories should be non-technical (the type of thing that a customer would write).
  2. Pick a user story and express the user story in a unit test.
  3. Write just enough code to pass the unit test. In other words, do the simplest thing that could possibly work to pass the unit test.
  4. Consider refactoring my code to improve the design of my application. I can fearlessly refactor because my code is covered by unit tests.
  5. Repeat steps 2 – 3 until I have completed the application (keeping in mind that the user stories might change over the course of the process of writing the application).

Otherwise, here are the steps that a “Test-After Developer” should do:

  1. Create a list of user stories.
  2. Consider the best design for the application (create separate controller and repository classes).
  3. Write application code that follows the design.
  4. Write unit tests for the code.
  5. Repeat steps 2 – 4 until the forums application is completed.

Someone who practices Test-After Development starts by writing application code and then writes a unit test after the application code is written. More to the point, a proponent of Test-After Development makes all of their design decisions up front.

The crucial difference between Test-Driven Development and Test-After Development is a difference in belief about the importance of incremental design. Practitioners of Test-Driven Development take baby steps in improving the design of an application. Practitioners of Test-After Development attempt to implement good design from the very start.

READ THE HAT’S BLOG

Comments?  Contact us for more information. We’ll quickly get back to you with the information you need.

SUBSCRIBE TO OUR NEWSLETTER