Test-driven development is a general approach to creating software. You may hear about red-green-refactor cycle which is the essence of TDD. If you are not sure if you have to write tests please take look at this article where I explained why you should do it.

Originally, TDD was a part of extreme programming but it’s now a separated programming technique. Knowledge of this technique is a very common requirement of job offers for software developers.

Want to receive useful tips, information about new Ruby gems and articles on a daily basis? Make sure you follow me and say hello!

We can just fit the essence of TDD in three repeatable steps:

  1. Write a test for non-existing code and let it fail
  2. Write a code for created test and make it pass
  3. Refactor code to meet your expectations

and then just repeat with every next class you will be working on.

At the end credits for the author: test-driven development was created by Kent Beck - https://pl.wikipedia.org/wiki/Kent_Beck

Want to become a better Rails developer?
Download for free the Introduction Rails patterns book and dive into the world of refactoring and easy-testable Ruby code today.
Join over 1,000 developers already subscribed to my newsletter and download the book. You can unsubscribe anytime:

Subscribe and get the book!