苏打

测试驱动开发-TDD

2020-01-14 · 1 min read
TDD Test

Test-driven development starts with developing test for each one of the features. The test might fail as the tests are developed even before the development. Development team then develops and refactors the code to pass the test.

Test-driven development is related to the test-first programming evolved as part of extreme programming concepts.

Test-Driven Development Process

  • Add a Test
  • Run all tests and see if the new one fails
  • Write some code
  • Run tests and Refactor code
  • Repeat

Example

Context of Testing

  • Valid inputs
  • Invalid inputs
  • Errors, exceptions, and events
  • Boundary conditions
  • Everything that might break

Benefits of TDD

  • Much less debug time
  • Code proven to meet requirements
  • Tests become Safety Net
  • Near zero defects
  • Shorter development cycles