Test-driven development (TDD) is really a way of thinking about our code that should be part of a standard development process. It is a development paradigm that starts with tests, and drives the momentum of a piece of production code through these tests. TDD means asking the question how do I know that I have solved the problem? instead of just how do I solve the problem? This is an important idea to grasp. We write code in order to solve a problem, but we should be able to prove that we have solved the problem through the use of automated tests.
The basic steps of a test-driven approach are the following:
- Write a test that fails
- Run the test to ensure that it fails
- Write code to make the test pass
- Run the test so see that it passes
- Run all tests to see that the new code does not break any other
- Repeat
Using TDD practices is really a mindset. Some developers...