[SE] Test-driven devlopment (TDD)

강승구·2023년 5월 9일
0

Test-driven development is an approach to program dvelopent in which you inter-leave testing and code development.

Test are written before code and passing the tests is the critical driver of development.

You develop code incrementally, along with a test for that increment.
You can't move on to the next increment until the code that you have developed passes its test.

TDD was introduced as part of agile methods such as XP.

However, it can also be used in plan-driven development processes.

TDD process activities

  1. Start by identifying the increment of functionality that is required. This should normally be small and implementable in a few lines of code.
  2. Write a test for this functionality and implemnet this as an automated test.
  3. Run the test, along with other tests that have been implemented. Initially, you have not implemented the functionality so the new test will fail.
  4. Implement the functionality and re-run the test.
  5. Once all tests run successfully, you mopve on to implementing the next chunk of functionality.

Benefits of TDD

  • Code coverage
    Every code segment that you write has at least one associated test so all code written has at least one test.
  • Regression testing
    A regression test suite is developed incrementally as a program is developed.
  • Simplefied debugging
    When a test fails, it should be obvious where the problem lies. The newly written code needs to be checked and modified.
  • System documentation
    The tests themselves are a form of documentation that descrive what the code should be doing.
profile
강승구

0개의 댓글