One of the things I’ve struggled and still struggling with is accepting the fact that bugs are inevitable. Whenever a bug gets reported on the code that I have spent hours writing I get crashed. I take it personally because that bug pops my ideal pink world bubble. So, let’s start by laying out the facts. No software is “bug-free”. There will always be bugs. But there is something you can do to almost annihilate them. Test test test.
Yes, testing has been around since the beginning of time but I wanted to write about the basics of testing and its benefits in case some new engineer gets discouraged by their first bugs. Testing can have many levels and categories but let's focus on the four basic categories:
- Unit
- Integration
- System
- Acceptance
Unit testing
Unit testing focuses on specific blocks of code and is responsible for checking the functionality of that specific unit. It can be applied on a class method or a module and it will lead you to write cleaner and more manageable blocks of code since the purpose of it is to test specific functionality of a single method. Unit tests don't have dependencies and are written during development and usually by the developer. Some of the benefits that come with unit testing are:
- Helps to break up code into smaller pieces that are responsible for specific functionality
- Breaking up code into smaller pieces will lead to a more maintainable and reusable code
- Since the testing happens during development you can catch bugs while developing
- After you are done with development and unit testing it is easier to make changes and you will feel more comfortable making them since that piece of code is already tested
Integration testing
After we have perfomed unit testing on our individual blocks of code we move on to integration testing which checks the functionality of single component. What that means is that we test how well, each unit of code, works with each other when combined. Integration testing usually happens during development and has dependencies since all units of code must be functional. Some of the benefits of integration testing are:
- Making sure that all small methods have the correct input and output in order to work well with each other
- Making sure that data are in the correct format when working with third party libraries and APIs
- Interfaces can be tested in this phase
- Making sure that changing the business logic doesn't break the whole flow
System testing
When we are done with the integration testing it's time to move on to system level testing which its main purpose is to test the application as a whole. It is important at this point to checks that the application fulfills the requirements. In order to fullfill this type of testing the application must be in a functional state. Some benefits of system testing are:
- Tests the application end-to-end
- Because this type of testing happens in a production like environment you can find and fix issues early
Acceptance testing
It is very important to check that the application complies with the end user requirements. To ensure that everything works as expected we use the Acceptance testing. This type of testing determines whether the application is ready for delivery. Some of the benefits of Acceptance testing are:
- Ensures that the business requirements are met
- Spots issues early before going to production