Test-Driven Development: What Is It And Why You Should Be Using It as a Developer to Reduce Your Bugs

Tomasz Dobrowolski
2 min readApr 9, 2022
Photo by Mars on Unsplash

Test-driven development is seen as a popular way to write code nowadays.

But what is it, and why should you be using it as a developer?

Test-Driven Development involves writing tests before you write your code

It’s that simple. The theory behind it is by writing tests that fail at first you do the following:

Plan out your code in a structured format

Writing tests first is hard.

It’s not natural, as we are testing for scenarios that are not in our application first. But by doing this, we are forced to think about our code.

Not planning your code can lead to rewrite after rewrite.

Write code that is loosely coupled

It is difficult to write a unit test for code with dependencies.

Unit tests do not account for dependencies well. We cannot mock a dependency that’s inside a function, considering a unit test can only test the output.

Therefore, if we have an object that is instantiated inside a function, we cannot mock this in our…

--

--

Tomasz Dobrowolski

I break down Software Engineering and Tech concepts | Backend Engineer 🐘