Member-only story

How to apply TDD approach for a Go application

TDD stands for Test Driven Development is a software development process which focuses on ensuring the updated code does not break existing features by always writing the tests first and then writing code to satisfy the written tests. In this article, let’s see how you can apply TDD for a Go application.

Donald Le
3 min readFeb 21, 2023

In software projects, we are often bound by the delivery deadline. Since everyone in the team needs to strive hard to meet the expected deadline, developers tend to avoid unit testing. As a result, the implementation code is not designed to have unit test in mind, which makes it really hard for developers to write unit test later when they have time. Without design for testing, like dependency injection, we will have to refactor a lot of code to write unit test. And because of lacking unit test, we can’t be sure whether our code changes break the existing functionalities of the app or not. This is a real block for developers to write the test and in the end, we might end up not having any test at all.

This is why we need to approach writing unit test with Test Driven Development. In TDD, you write the test first, then write the code just…

--

--

Donald Le
Donald Le

Written by Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

No responses yet