No glorified hello worlds here
Tags: programming, unittesting, testing, softwaredevelopment
Published: 2018-01-08 11:24:16

---
title: "No glorified hello worlds here"
published: true
tags: programming,unit-testing,testing,software-development
cover_image: https://i.imgur.com/KwCxLpS.jpg
canonical_url: https://medium.com/@elvis.pestana/no-glorified-hello-worlds-here-8678ec3bc012
---

In the years I have been developing software, mostly web-focused, something was always missing: Unit testing. This was due to have been in companies whose culture abhorred anything that leads to delays, even justified. Something that could not be easily justified, cost-wise, as an advantage would be throw out the&nbsp;window.

My experience is limited to personal projects with perfect world requirements. So, in the end, I consider myself as a beginner on unit&nbsp;testing.

Where to start? I can analyze — and have analyzed — projects with unit testing implemented but nothing replaces hands-on experience in real projects with users and it’s edge cases. Glorified “hello worlds” do not&nbsp;count.

Going back a little, I understand the advantages of unit testing. I’ve seen projects with testing implemented and the benefits it’s bringing to the table, but it’s been impossible to convince management of its importance — and even other senior developers. Maybe I’m not good at communicating the pros and&nbsp;cons.

Finally, the other issue that unit testing brings. Testing is like digital security. Whoever is responsible for this will always be in an ungrateful position to defend. When everything is going well, that unit testing is doing its job properly and the devs reap the benefits someone will probably say — or at least&nbsp;think:

> Why are we wasting time with unit testing if everything is going so well? Why am I paying&nbsp;you?

Or even when the **inevitable** bugs&nbsp;occur:

> Why are we having problems? I thought we had unit testing. Why am I paying&nbsp;you?

![](https://cdn-images-1.medium.com/max/1024/1*CfdxLFqER3D-buDMmBh5sw.jpeg)<figcaption>Photo by <a href="https://unsplash.com/photos/5oyFrBF33Q4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Edu Lauton</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

**This is aggravating.**

One time I was meeting the teams on a new company that, eventually, I joined and I remember asking “Do you do unit testing?”. The happy answer was “of course”. I was happy that I would be joining a company where I could get experience with unit testing on real-world projects. Little did I know he was referring to end-user testing. There was a team dedicated to testing entire user processes, from start to finish, to make sure everything was according to the requirements. This was good to have, but it was not unit testing. I later found that this company had an annoying habit of using industry standard names that meant something completely different inside the company. Consultants? = Glorified salesmen.

Articulating the advantages seems hard when even seasoned devs don’t want or care about unit testing. In real life, we also have to take into account company policy, personal interests — I want this project done ASAP! — which usually means getting closer to that&nbsp;bonus.

What are the usual pros? Let’s list&nbsp;them.

- Finds bugs early — The sooner a bug is found, the less likely it appears on production.
- Improves code quality and readability — A big advantage for big projects.
- Facilitates changes giving greater confidence to the developer that his changes did not break existing functionality, therefore…
- … boosts developer productivity.

Sum all of the above and you have the biggest pro since it reduces costs in the medium to long-term.

> I can analyze projects with unit testing implemented but nothing replaces hands-on experience in real projects with users and it’s edge cases. Glorified “hello worlds” do not&nbsp;count.

What are the downsides? Let’s take a&nbsp;look:

- Does not guarantee bug-free code. This is the obvious one, but somehow some people believe unit testing to be&nbsp;magical.
- Time-consuming. Same as saying it costs more. Can’t release the project on time, or the project must have features cut. Managers/Clients don’t like to hear&nbsp;that.
- Unit tests can/will have bugs. This one is down to the quality of the dev team. Have less discipline here and you will get in&nbsp;trouble.

It boils down to cost. A company culture that does not allow a developer to fail will not have unit testing. If you cannot count on your teammates to help, you will not have unit testing. If your company only sees you as a row on an excel spreadsheet, that means you will actually get burned with unit testing (cost) and then you will not have unit&nbsp;testing.

![](https://cdn-images-1.medium.com/max/1024/1*Jsodd7y2uNxBeWED_ufuHg.jpeg)<figcaption>Photo by <a href="https://unsplash.com/photos/82TpEld0_e4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">G. Crescoli</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

**After reading much about unit testing the greatest advantage I see is that it makes us focus and reflect on the code written. If your code is too big or hard to read, you will most likely refactor it. In a team, this will lead to increased productivity with higher quality code bases. As a developer, I don’t need any more reasons to like unit&nbsp;testing.**