Want more awesome content? Sign up for our newsletter.
Every tech company should write tests when they build software or apps.
Yes, it takes time, and yes, it’s hard at first, but well-written tests may be your one and only parachute when you’re falling into the tangle of bugs. This is my goal today: give you a useful example to help you spend all the time you wasted on debugging in a different (and probably much funnier) way.
How much time do you spend debugging your code?
TDD: real-life usage example.
- Red phase – create a test and make it fail.
- Green phase – make the test pass by proper implementation.
- Refactor phase – remove duplication and improve design and readability of your code. It takes just a second to run a suite of tests after every change you make.
Okay, you still have one-hour-time less for plugin B compared to TDD plugin (and plugin A it’s barely two hours longer than the TDD plugin), but consider that this is only the first change in requirements: things will get much worse as new modifications arise, as reported in the following chart that describes the cost of implementations with the two different developing approaches.
Time spent on writing tests, then, is not wasted time. It’s the time you invest now to save your time later. Basically, in the long run, it could cost you a fortune if you don’t do TDD.
- Increase of the internal quality (perceived by the development team) and of the external quality (perceived by users) of the software;
- Increase of the programmer’s productivity and cut of development costs;
- Flexible software architecture, easily adaptable to the customer needs;