Why is it Important for Developers to Write Tests?


It’s a decades-old debate of whether developers should write tests or not. While some think it’s important, others believe that it may be too much to ask from developers. In this article, we’ll focus mainly on the “for” side of the argument while exploring the other side briefly as well.

Let’s start by answering the main question: Why should developers write tests?

  • To save time and money
  • To reduce bugs
  • Tests allow you to make changes in your code quickly
  • Tests enable you to finish work faster
  • Instant feedbacks, better code
  • If developers continue to deliver quality codes, they increase their chances of a faster promotion

These are some of the reasons why developers should write tests and hopefully, they are enough. You may be wondering how writing tests save time and money since it takes extra time for developers to do so. And while it holds in the short-run, but in the long-run, it will take much more time to fix bugs that could’ve been avoided by tests. 

The Concept of Developer-Based Testing

In some teams, developers are expected to conduct unit testing at a minimum. They are asked to produce automated, integrated, and code-based tests. Building tests take time and instead of doing so, most developers prefer to use that time to create new code and features. Developer-based testing is a time-consuming process that slows down development and decreases code productivity. But competitive developers prefer to thoroughly test the code themselves because they don’t like QA testers or customers pointing out defects to them. Writing tests before QA adds another layer of quality check that can be very helpful to ensure quality, considering that developers are not the only ones prone to errors. Also, the quality of code reflects the credibility and capability of a developer. Sending a poorly-written code can have adverse effects on a developer’s reputation. That’s why developers should take some time out to write tests themselves. Finally, if developers write tests, it can save time by decreasing release issues, downtime of production, and the number of visible customer defects. 

Essentials of Developer Tests

1. Limitations

Many developers think that there are no need for them to write tests since they work hard and leverage test management tools to make sure that the code they write is flawless in the first place. They also think that writing tests are more of a tester’s job, so why waste time? Studies suggest that even the most experienced programmers struggle to look closely and miss out on important bugs. This is why hiring QA experts for testing is crucial.

2. Streamline Your Process

If you’re pursuing the idea of developer-based testing, you need to find the right balance. Developers are already occupied with plenty of work and they can’t afford to waste a lot of time on manually writing tests. Also, the tendency to make errors in manual testing is much higher. Therefore, you need to plan and execute a process that is streamlined.

3. Get a Faster Feedback Loop

A feedback loop is a process of adding code, getting feedback on it, and repeat. The faster this cycle is, the more productive is the process and the lesser the number of bugs is. Feedback can be easily gathered using collaborative test management tools that ease communication between fellow testers, developers, test managers, and other important stakeholders.

4. Increased Confidence When Changing Code

Good test coverage provides a safety net for making changes in the code, making you and other developers in your team more likely to refactor that code smell. This will make you worry less about the risk of creating more work for yourself by potentially breaking something. The net effect of this is a better codebase for all.

Why Developers Avoid Writing Tests? 

1. “It Takes Too Much Time”

That’s the main excuse we hear from the developers. But as explained above, the reality is opposite to this in the long-run. Writing tests not only help save time and money but also significantly reduces bugs. But developers do have a valid point, they face a tremendous amount of pressure of meeting tight deadlines and often, inexperienced managers fail to understand developers’ situation and decide not to extend strict deadlines. But this still doesn’t deny the importance of writing tests.

2. Fear of Writing Tests

Developers often have a big ego. They spend hours and hours writing, reading, and reviewing code. They, in a way, get attached to it and if someone tells them that there is some problem in their code, they’re never ready to admit or at least consider the possibility. And this overconfidence and insecurity can be a major reason behind a miserable product. Developers are afraid that the tests they write will reveal bugs in the code they worked on.  


The conclusion is entirely up to you. You have to pick a side and decide whether developers should write tests or not. This article discussed both sides of the argument for readers and leaders to make an informed decision. What’s important is to keep your goals in mind and what works for you because there are pros and cons to everything. We believe that testing is a collaborative process and it requires participation from both developers and testers. Developers need to put their insecurities aside and play their part in testing while managers must ensure that they don’t overburden the development team.