All you need is testing
Testing tools for the real world
Working on legacy code sucks. I easily lose control of my own code and I have no perception about where the entire project is going! If I work in a team, you can imagine is much worst! Testing ensures the project and the developers to have exactly what we want and the results we expect.
But... we don't write tests because we don't have time! This is simply WRONG! How many times you have heard this stupid sentence?
How many hours and days you spend debugging? Isn't it boring? How can maintain the software and prevent the code to rot, being useless and dirty in our repository? How many boring bugs and tickets you are ready to solve and lose time again? Before or after, the customer will know about the situation and he will not be happy! We don't want this situation! So write the tests, follow the best practices and be a good boy!
100% code coverage does not ensure your code works!
That's true! You can write even more tests to cover every test case. Be sure to have all kind of tests: unit test, BDD and functional tests to avoid this pitfall. This is one of the few cons you can find about testing. The number of advantages you can find on testing is much more and they are priceless!
But we have our own framework!
Cool. You know I hate custom frameworks but if you have a framework you MUST write your tests to let all features to be efficient and ready to use for other developers, So this is not an excuse! If you have your own framework, writing tests is mandatory.
But testing is HARD!
That's even true but not always! Practice TDD and simplify all you can simplify. That will make things easier to maintain and update. Do whatever you can if you work with database and third-party service. You will see how comfortable is to work with something you can demonstrate it works! And when you update something, you run the test suite again and see if every part is working in the same way we expect. How many times you have updated some and you have broken some other feature that uses the same code elsewhere?
You have to learn how the testing framework works. I think how
- Unit testing framework: every backend programming language has one or more testing framework. Choose your favorite!
- Mock database: if your application use database, data must be mocked and you test the database with the expected data set. If you can use fixtures and a test database is great too!
- Fake data for forms: there is small software that helps you to fill forms generating the desired string type (name, fiscal codes, dates, etc.) or numbers.
- Third party services and dependencies: file system, storage, messaging API and services must be mocked or you must find a solution to test a specific part of the software independently.
- Browser testing: Cypress, Protractor, Enzyme, etc.
- Selenium: still a good solution for browser automation but I think Cypress is great too!
The world of software development offers many testing tools because we have to write all kind of tests to reach our aims and live a happy life! If you want to sleep during the night and be free from stupid bugs and tasks, write even more test to be sure everything we do is working fine! You will see the benefit of this practice during the time. When a project will scale and become bigger, you will that testing is a fundamental part of the entire software development lifecycle.