The thoughts of Spicer Matthews

Prioritizing TDD Friendly Languages and Frameworks

Date: Mar 18, 2023

Unit testing and Test-driven development (TDD) are crucial elements of software development. Unit tests ensure individual code units function correctly, while TDD emphasizes writing tests before writing code to meet expected requirements.

As someone who enjoys TDD but dislikes writing unit tests, I appreciate the importance of testing and value an efficient development process. Unit tests should make development more enjoyable and not be an extra burden. They should be tools that help developers work faster, rather than additional tasks.

"Said a different way, unit tests when written to speed up my development process are amazing, but they are super annoying when written as a chore."

When choosing a programming language or framework, prioritizing those that are easy to use with TDD is essential. Golang is excellent for TDD when developing web apps because testing is simple and fast, making the process more efficient. In contrast, testing in Javascript can be tiresome, particularly on the frontend, where writing unit tests often feels like a task rather than a helpful tool.

Changing personal development habits, such as moving from browser refreshing to running unit tests in PHP can pay huge dividends, despite taking time to adjust. This shift may not necessarily make one a faster developer on day one, however since PHP is fairly easy to test the benefits will be noticeable over time.

I was prompted to write this post because I've noticed that many projects choose programming languages that are difficult to test, or new technologies that are associated with hard-to-test languages. For example, Node.js is a popular choice for serverless computing, even though it is harder to test than some other options. This has always confused me. The argument that Node.js is great because it is the same language on both the front and backend seems weak. What happen to picking the correct tool for the job?

Of course, there are pros and cons to any technology decision, and it's not always possible to prioritize testing over other factors. However, I believe that developers should give greater consideration to languages and frameworks that facilitate TDD, as this can ultimately increase productivity.

In short, unit testing should not be viewed as a chore, but as a valuable tool for developers. By prioritizing languages and frameworks that make it easier to write and run tests, we can improve the quality of our code and enhance the overall development experience.

Did you enjoy this read?

Help a brother out -- follow me on Twitter.

Join My Newsletter

1,000+ people have joined to following along as I share on software and bussiness.