Mar
12th
Thu
12th
Unit Testing: first or last?
Testing is good, and so is unit testing. But how beneficial is TDD? TDD implies that you write the tests first, then write the code that satisfies them. A study from 2005 compared the results from a small sample of two CS student teams, one doing TDD and the other one writing tests after the code. It showed interesting results, but it’s not easy to figure out a conclusion, and it seems that it all depends if the goal is productivity or quality.
I once wrote my tests first, then I wrote my code, then I ran the tests, my code passed every test first time….the tests and the code were both wrong.