DEV Community

Cover image for Solving the FizzBuzz exercise with TDD
Christian Vasquez
Christian Vasquez

Posted on

Solving the FizzBuzz exercise with TDD

Test-Driven Development (TDD) can be a scary concept to hear at first.

How are you supposed to write code that test your code... even before it even exists?

Well, yeah. It can be done and it's a really awesome way of writing code.

Some of the benefits of TDD are:

  1. The code coverage will (most of the time) be pretty high.
  2. There won't be more tests "to write later".
  3. You can refactor your code with more confidence since there should be a bunch of tests that will make sure you don't break anything.
  4. The code will be testable from the beginning because you would not be able to do it without it from the get go.
  5. Probably a few more that I can't remember right now 🤓

Alright, enough chitchat. I've decided to do it while solving a well-known interview question/exercise named FizzBuzz on this video:

Discussion (0)