# Unit tests and Test-Driven Development

**URL:** <https://boards.straightdope.com/t/unit-tests-and-test-driven-development/437739>\
**Category:** Factual Questions\
**Created:** [February 15, 2008, 2:57pm UTC](https://boards.straightdope.com/t/unit-tests-and-test-driven-development/437739 "2008-02-15T14:57:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweeteviljesus](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@sweeteviljesus](https://boards.straightdope.com/u/sweeteviljesus)\
**Post date:** [February 15, 2008, 2:57pm UTC](https://boards.straightdope.com/t/unit-tests-and-test-driven-development/437739/1 "2008-02-15T14:57:52Z")

</div>

I have never been entirely sure what to put in unit tests and most references I have seen use really contrived examples like a calculator. Does anyone know of a good example of a test suite written for a small database-backed webapp? (Ideally, one that uses Tapestry 5 or Seam, but I’ll take what I can get.)

Also, regarding TDD, I have never been really clear on how much to write before testing. The examples I have seen were so fine-grained as to be an impediment to productivity. I can write a class that has just enough code to pass a test but it seems like you wind up going through too many iterations between the test and the code. Does anyone know of any decent examples of this?

Thanks,  
Rob
