11.1 The Purpose of Testing
There are several reasons to perform testing:
- Check that requirements/specification has been met.
- Exercise solutions to try to break them.
- Continuously evaluate solutions to ensure we don’t regress.
Each of these can be sub-divided into:
- Functional
- Testing what the code does.
- Non-functional
- Testing how the code does it (such as how fast it performs, the user experience, etc.)
When should we write our tests? The answer depends on the purpose of the test. Tests to check our solution meets requirements are best written first. The process of writing these tests serves to help us understand the requirements. Tests to ‘break’ our system are best written after our implementation as they help us sure up our solution, uncovering extremes under which our solution fails. Finally, tests to monitor our solution can only be written once our solution is operating.