From the course: Agile Software Development

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Test-driven development (TDD)

Test-driven development (TDD)

- Another core practice of extreme programming is test-driven development. Test-driven development means you never write any code until you have written and failed a test for it. It is a three-step process. The first step is to write a test for a function that is yet to be written. The code will not compile. The next step is to write the function so you have just enough code to make sure the code compiles. The test should fail. If the test passes, the test is inadequate to verify any functionality and should be refactored. The third and the last step is to complete coding of the function to meet requirements of the test. After you write each test, you refactor the code to meet the requirements of the test. Then you write another test and refactor the code to pass the test. This process continues until you have exhausted your list of tests and your code is complete. The essence of test-driven development is thinking about test scenarios before implementation. This may appear a little…

Contents