10

I am beginner in developing test cases, and want to follow good patterns for developing test cases rather than following some person or company's specific ideas. Some people don't make test cases and just develop the way their senior have done in their projects. I am facing lot problems like object dependencies (when want to test method which persist A object i have to first persist B object since A is child of B).

Please suggest some good books or sites preferably for learning design pattern for unit test cases. Or reference to some good source code or some discussion for Dos and Donts will do wonder. So that i can avoid doing mistakes be learning from experience of others.

2 Answers2

8

Xunit Test patterns, simply a must have.

Unit testing is hardly news, but simply writing a ton of tests guarantees you no bliss. Gerard Meszaros's xUnit Test Patterns distills and codifies the crucial meta-knowledge to take us to the next level. Why do good tests go bad, and how do you fix them--it's as simple and groundbreaking as that. Smells and antipatterns arise in tests that cripple their maintainability. xUnit Test Patterns exhaustively describes those pathologies and provides the prescription in the catalog format familiar since 1994. But fear not - every motivation and pattern includes at least one source-code example and the explanations are couched in clear, direct language. If you're ready to promote your test code to the same level of care and craftsmanship that you devote to production systems, grab a copy of xUnit Test Patterns and get cracking...

gnat
  • 20,543
  • 29
  • 115
  • 306
KeesDijk
  • 8,968
2

http://en.wikipedia.org/wiki/Test-Driven_Development_by_Example

Kent Beck is the originator of the name "Test Driven Development", which is one part of the eXtreme Programming style of development that Beck and his team developed in the 1990's. His books on the topic was one of the sparks of the agile movement.

The above linked book is his book on Testing, and is a clear and good introduction to how to not only test, but make your development test-centric, and the benefits it creates.