loading words...

Dec 21, 2018 13:06:02

How Unit Tests Saved My App

by @valentino | 247 words | 37🔥 | 335💌

Valentino Urbano

Current day streak: 37🔥
Total posts: 335💌
Total words: 161812 (647 pages 📄)

I came back to an application after almost a year spent without opening up the project and I felt lost. I recalled the basic structure of the app but didn't remember the specifics.


The Problem

Someone had opened a bug because the app would crash under certain specific conditions. Thanks to detailed reproduction steps I reproduced the problem right away.

I thought fixing it would take ages since it looked like the problem was deep inside the class that handles serialization to disk. I put some breakpoint where I thought the problem was and it blazed right through. Wrong target.

Then I remembered that the app was fully unit tested if there was a problem it surely would catch it. Turns out it wasn't just a single problem, there were multiple factors that combined caused this undefined state.

The unit tests were able to isolate each problem on its own and a bit of knowledge of the application put 2+2 together.


Result

App fixed in less than 20 minutes, while I would have wasted at least an hour doing it manually.


Start Testing

It might seem like a daunting task at first, especially if you already have a legacy application. You don't need to unit test everything right away. Each time someone files a bug and you resolve it to add a test to be sure that there aren't any regressions. With time your test suite will grow organically and without hassle or a huge time dedicated to it.

Originally published at www.valentinourbano.com

  • 1

    @valentino TDD is really a skill set that all programmer should know at this point. Especially since the iterative building of an app is paramount in today's regular startup world.

    Jason avatar Jason | Dec 22, 2018 19:03:00
  • 1

    @valentino "I came back to an application after almost a year" imagine all the poor souls who don't know how to unit test ?

    Basile Samel avatar Basile Samel | Dec 21, 2018 13:12:51
contact: email - twitter / Terms / Privacy