Test-driven Development

allacyn
Posted on in Blog, Dev Tech, Technologies

What is Test-driven development?

Test-driven development (TDD) is a software development process with short, repeated development cycles. The whole idea comes down to testing before a line of code is written. The goal of TDD is to have better design and verify code.

Steps:

  1. Write- an automated test case that will fail.
  2. Run- make sure the test will fail for the expected reason.
  3. Write- code that will cause the test to pass.
  4. Run- to make sure all test cases now pass.
  5. Refactor- clean the code up.
  6. Repeat- the cycle to move functionality along.

A passing test from step 2 will require step 1 to be redone, if the test fails you will continue on to step 3. If on step 4 the test fails you will have to go back to step 3, but if the test passes you will move on to step 6.

What are the benefits?

  • Detects defects more quickly
  • Decreased use of debuggers
  • Detect changes in code behavior
  • Code is modularized and flexible
  • Cuts down on code implementation time
  • Concerned with interface before implementation
  • Developers write more tests, are more productive

What are the drawbacks?

  • Can be difficult to use
  • Can lead to a false sense of security
  • Maintenance of tests can be expensive
  • One developer can lead to shared blind spots
  • Coverage and detail in tests is not easily recreated
  • Management might see writing tests as a waste of time

Do you use TDD? What do you feel like some of the benefits and drawbacks are?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>