TDD (Test Driven Development) is a computer programming method that consists of small iterations. In this method you begin by writing the test cases covering the new functionality, then you write the production code necessary to make the test pass, and after that you refactor the code to make it more maintainable. Writing the tests before writing the code guaranties immediate feedback after changes are made. TDD (test-driven development) is a technique for designing the software as well as testing it.
In Test Driven Development (TDD) automated unit tests are written before the code is actually written. Running these tests give you fast confirmation of whether your code behaves as it should.
TDD can be summarized as a set of the following actions:
(1). Writing a test
In TDD (Test-driven development), you begin by writing a test. In order to write the test, the programmer must fully comprehend the requirements. At first, this test will fail because it is written prior to the feature.
(2). Run all of the tests and make sure that the newest test doesn’t pass
This insures that the test suite is in order and that the new test is not passing by accident, making it irrelevant.
(3) Write the minimal code that will make the test pass
At this point you need to write code that will successfully pass the test. The code written at this stage will not be 100% final, you will improve it later stages. Do not try to write the perfect code at this stage, just write code that will pass the test.
4. Make sure that all of the previous tests still pass
If all tests now succeed, the developer can be sure that the code meets all of the test specifications and requirements and move on to the next stage.
5. Refactor your code
In this stage you will clean up and improve your code. By running the test cases again, the programmer can be sure that the refactoring / restructuring has not damaged your code in any way.
6. Repeat the cycle with a new test
Now the cycle is repeated with another new test.
In Test-driven development you always repeat the stages mentioned above (adding tests that will not succeed, making them succeed, and refactoring of the code). Getting the wanted outcome at each step greatly increases the developer’s confidence, productivity, and shortens the time to market.
Want a specific video tutorial? Add a resource to the list? Stop by the forums, and let us know!