Follow @RoyOsherove on Twitter

How do you avoid bugs in your unit tests?

Oren tries to answer from difficult questions about TDD. One of them is related to how you'd make sure that your tests don't have bugs in them - which is a very important aspect of trust-worthy tests:

One of the best ways to make sure that you test is not buggy (a smoke test, if you will), is to to make sure it fails when it should.
That's why in TDD, you always start with a failing test.
You actually *run* the test and watch it fail before you make it pass.
This has two reasons:

  • To let you know that you have a bug.missing feature in your code, and to direct you to fix that target. now that the test passes, you can fix it , and then see the test fail.
  • If you can't make the test fail when it should, it probably has a bug so if the test fails to begin with, and then passes when you fix the *production* code, you're good. but if your test passes from the get-go, before you even fixed the production code, you know your test isn't good enough..



Moving to FeedBurner

Microsoft's SharePoint treats FireFox as 2nd class citizen