# Testing

## Why people don't write tests?

People don't write tests for the following reasons:

* lack of knowledge on how to do it
    
* their code is not testable
    
* fear of being judged due to their own ignorance
    
* lack of a competent person in the team (e.g. tech lead) who is aware of the benefits of writing tests
    

Usually, this is accompanied by additional excuses such as:

* why bother, it works anyway?
    
* I tested it manually
    
* I don't have time for that
    
* it's too much work
    
* what will it actually give me?
    
* nobody writes tests in other companies either
    
* this application is not widely used
    

Unfortunately, this is the reality in many cases, but it can be changed.

## Why test at all?

It is enough to reverse the previously given examples and everything will immediately make sense. The following steps should be taken:

* acquire knowledge on how to test code
    
* improve programming skills. Writing tests requires good quality code. Otherwise, tests become very complex and time-consuming.
    

What do we gain when we write tests?

* detecting errors during development
    
* we have confidence that our code works (if properly tested)
    
* we don't have to test anything manually - tests check the application for us
    
* we immediately detect regression errors
    
* we write better, maintainable code
    
* in the long-term perspective, we save enormous amounts of time
    
* we sleep more peacefully :)
    

## When not to test?

There are situations where writing tests is not advisable.

In the case of creating a prototype or MVP, we want to deliver a solution as quickly as possible. Such code will probably be heavily modified or completely unnecessary. Therefore, testing it would be a waste of time.

When dealing with "legacy code", testing may prove to be very complicated or impossible. Such code requires refactoring or complete rewriting.
