Professional developers' code contains fewer bugs than novices', but it's not because they're brighter, more detail-oriented, or able to see the code from bean to cup. The real reason is that they write tests.
Automated testing is an integral part of the programming process in a professional environment. Tests are the only reliable way to make sure your code works. They don't eliminate bugs, but they help you keep the number of bugs at an acceptable level. Tests check that changes to one part of the system haven't broken other parts.
But tests are needed for more than just checking that the code works. There are other types of automated tests, such as performance or vulnerability tests. First of all, programmers are responsible for functional tests. These tests verify that the code performs its intended task from program users' perspective, for example:
- To check if the programmer has written some code that's responsible for user registration
- To carry out a functional test that shows whether the user can register
According to the degree of isolation of the tested parts of the code, functional tests fall into three general categories: