As the size and complexity of a software unit increases, it can become quite time-consuming to ensure that it behaves according to its specifications each time it is altered. For this purpose, automated testing becomes invaluable by increasing the overall reliability and quality of a software unit, without constant manual testing.
There are various levels of testing that a project can implement, ranging from unit tests at the function or class level, up to integration tests that make use of an entire application stack. Most testing frameworks provide for this entire range, perhaps just with the addition of a few tools.
Also worth mentioning in relation to testing is the practice of test-driven development, in which a developer first creates (initially failing) a test case for a desired improvement or a new feature, and then does the minimum amount of development to make the test case pass. To finish it off, the developer will then review the written code and refactor it to acceptable...