Sep 01, 2016

Why automated tests matter?

blogpost author photo
Michał Brodecki
blogpost cover image
What are automated tests? As the name suggest, these are tests that automatically verify your code. So, can I write an application without them? Of course you can! So why do I need them? Isn't that I will spend more money on the development process because my developers will need to write tests for funcionalities? Well, time for some explanation. 

Simple example

To understand what tests really are, we need to explain how implementation of the basic funcionality looks like. Lets imagine the situation, that your application has a list of employees with their data such as name, surname, phone number and address. But each time you want to add new employee you need to ask your developer to do so, because there is no such button in the application like "Add new employee". So you are making a decision - please add this funcionality so I can easly add new employees to the system. However your developer is on a holiday right now so his friend will implement it. He's as good as you developer, works in the same technology. You agree, because it's a small change. What can go wrong?

Case 1 - there are no tests

Ok, your new developer agrees with you that this is a small and quick job. He adds a button, he plays around with it and comes to you with job done. You got your button and you agree it works. It's been a week now since this button is present. You have added bunch of new employees. It's the end of the month and it's time to process invoices from your employees. You notice a strange thing, because you cannot access the invoicing module for newly created employees. They seem "broken" somehow. It occured that developer forgot to implement small mechanism for newly created employees that sets up invoicing module for each of them and you cannot access it right now. Sad, isn't it?

Case 2 - we have automated tests

It's still a quick job, but your developer starts from writing tests for newly created employee. And he discovered that some tests failed because newly created user has no invoicing module. Ok, your developer is alerted about the situation, he dives deeper and notices that creating a new employee requires a little bit more. He adds what it needs to be added and voila, all tests pass. The work seemed a little bit larger than in the first case, but right now it actually works and everyone can sleep well.

Why tests are important?

Let's summarize what automated tests gives you:

  • Painless possibility to develop your application

  • Reliability

  • Newly added funcionalities are not breaking existing ones

It's pretty convincing, isn't it? Belive me, project with automated tests are way more easier to develop. You are sure, that each of existing components works well even after new funcionalities arrival.

4 main advantages of automated tests

You may hear that creating the software without tests is quicker and faster. Is it true? Testing is the part of developer's job. If your developer said that he finished the funcionality but he didn't write any test for it, it means that this funcionality is not ready and it doesn't even work. Still not convinced? Ok so here we go with 4 main advantages of testing:

  1. Quicker development
    It's pretty simple and easy to understand. Your developer doesn't waste time (and time is your money) for clicking through the whole application and checking if new funcionality broke anything else. And if you have big application, checking everything 
    Implementing a new funcitonality consits of:

    1. writing tests

    2. implementation of the funcionality

    3. optionally - fixing these parts that were affected by the change and don't work

  2. New person in the team has a better start
    Big projects have large amounts of code. It's pretty obvious. Whenever some new guy joins the team it's easier for him to jump in to project. Of course he will need some time to understand the application and the whole flow but after that he can quickly grab some task and start work. He will just need to ensure that the new thing he implemented has a good test coverage and doesn't break other tests.

  3. Updating libraries is safer
    Sometimes it is required to update some parts of the application. Libraries are packs of components that may be used in your application. For example, your developer doesn't need to write authentication module from scratch. He can use a library and adjust it to his requirements. However, it might be needed to update the version of the library. After the update you can just verify if all tests passed.

  4. Bugs are easier to spot
    Belive me or not but developers are human beings and sometimes make mistakes. Some of the are easy to spot and some could take a lot of time to track down. In most cases bug appears if developer didn't predict some edge case. So if the bug occurs he just need to write a test case for that particullar situation and fix it in the code. If the test pass, it means that the bug has been fixed.


I hope now you understand why tests are important. If you are still not convinced don't hesitate to comment or contact us directly. We can arrange a hangout and then we will surely convince you :)