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.

20
  • 1
    @Mark: I don't know any of them and I'm very interested in what others will say about them in order to improve my technique in that particular field. Now I agree the question lacks of precision. Maybe we should suggest Maddy to precise his/her question?
    – user2567
    Commented Dec 30, 2010 at 12:16
  • 2
    @Pierre that's why I asked the question in my first comment.
    – user8
    Commented Dec 30, 2010 at 12:17
  • 1
    Sometimes it just isn't practical to offer more precision or maybe the OP doesn't know enough to offer more precision. Maybe they are looking for design patterns to better understand how unit testing works because other examples aren't grokking for the OP. I certainly hope no one has voted to close this question as it could prove to be very useful. Commented Dec 30, 2010 at 14:09
  • 1
    @Michael: That close vote seems to be a little unfair here (please note I'm not blaming you here, I'm just "harumphing"). It is a question despite the fact it literally doesn't have a question mark at the end of it. I, personally, have searched for unit testing examples, and they are surprisingly hard to find if you don't know enough about them. If a question like this can't be asked here, then where else are we supposed to go? Harumph! Commented Dec 30, 2010 at 15:00
  • 2
    @Maddy - you should add your comments to your question. Your question is a little vague and adding more detail to your question will help.
    – Walter
    Commented Dec 30, 2010 at 16:11

2 Answers 2

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...

2
  • Can u please refer some site to quickly start upon. I can read this book latter when i get time.
    – Maddy.Shik
    Commented Dec 30, 2010 at 12:27
  • 3
    Explore the link a bit further, start for example at xunitpatterns.com/Organization.html
    – KeesDijk
    Commented Dec 30, 2010 at 12:33
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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.