Photo by Oskar Yildiz on Unsplash

Test Driven Development

Sam Johnson
3 min readJan 19, 2021

--

A positive and productive technique

As a programmer in the early stages of my understanding, I have started to really grasp what each line of code is producing. Moving forward in my own development, I am able to look forward at each task or project and make a clear decision on what and how the code should be doing. This has a lot to do with how my bootcamp has been structured. Each project that we have completed requires almost a dozen tests to be passed for each section. This allowed me to fully understand what was going on in each project; and even in the moments I was really struggling with a project, I was able to take a look at each test being run for some sort of clue.

All that brings me to the topic we are talking about here: TDD or Test Driven Development. As we grow as developers, we will be asked to work and be productive more and more autonomously. Personally, I have always struggled with being productive on my own; but having some clear goals outlined for you is a great motivator. That is essentially what we are doing with TDD, setting clear bars that our code must pass before we write any actual code towards the specific project. That’s what sets TDD apart from others, writing the tests first will hopefully steer any developer away from writing lazy code or taking any shortcuts. Now for me, previously, just getting all the tests to pass by any means was a success and I could move on; but when we have to work on a team that relies on using your code further down the line, we need to make sure that the code they are receiving is doing everything that they expect it to do.

How to write good tests.

Once you’ve figured out the goal of what you are working on, then you can begin writing tests. It is highly recommended that you write many smaller tests rather than a few tests that cover more so that you can quickly narrow down what in your code is not quite right. Once again, it is important that you write the tests before any of your code is written. Another reason to do so is to ensure that the code you’re writing can actually be tested and that all edge cases are accounted for. I’m sure you’d be in a whole heap of trouble if you write some code thinking you’ve covered all your bases and then a few days later it comes back with some bugs and no one knows why.

Conclusion

The most important thing here is being thorough, sure it might seem tedious at first and might seem like it’s slowing you down. However, in the long run, getting in the habit of writing these tests will help you not to overlook any little detail and should help you avoid more errors in the code. This is why TDD is one of the more important things young developers can pick up on moving forward in this field.

--

--