Art of Unit Testing - Official Book Wiki > Chapters > 1. The Basics Of Unit Testing

1. The Basics Of Unit Testing

Table of contents
  1. 1. Opening Paragraph 

   

Opening Paragraph 

One of the biggest failed projects I worked on had unit tests. Or so I thought. I was leading a group of programmers to create a billing application, and we were doing it in a fully test-driven manner – writing the test, then writing the code, seeing the test fail, making the test pass, refactor, rinse, repeat.    

The first few months of the project were great; things were looking up, and we had tests that proved that our code worked. As time went by, requirements changed, and we were forced to change our code to fit those new requirements. Whenever we changed the code, tests broke and we had to fix them – the code was still working, but the tests we wrote were so brittle that any little change in our code broke them, even though the code was working just fine. It became a daunting task to change our code in a class or a method for fear of changing all the unit tests involved with that unit being tested.   

Worse yet, some tests became unusable because the people who wrote them had left the project and no one knew how to maintain the tests, or what they were testing. The names we gave our unit test methods were not clear enough. We had tests relying on other tests.We ended up throwing away most of the tests less than 6 months into the project.    

It was a miserable failure because we let the tests we wrote do more harm than good – they were taking too much time to maintain and understand than they were saving us in the long run. So we stopped using them.I moved on to other projects, where we did a better job writing our unit tests, and even had some great successes using them, saving huge amounts of debugging and integration time.    

Ever since that first project that failed, I’ve been compiling best practices for unit tests and using them on the next project. Every time I get involved in a new project, I find a few more best practices. A solid naming guideline is just one of those. Understanding how to write unit tests, and making them maintainable, readable and trust-worthy is what this book is about– no matter what language or Integrated Development Environment (IDE) you work with.    

This book will cover the basics of writing a unit test, then move on to the basics of Interaction testing, and from then we’ll move to best practices for writing, managing and maintaining unit tests in the real world.

Download the first chapter as PDF 

Comments? Errata?

 Be heard!

    

Tag page
Viewing 15 of 25 comments: view all
I myself is a software developer for the limewire pro , Just the opening paragraph had grab my interest, what I most concern is understanding how to write unit tests, and making them maintainable, readable and trust-worthy from this learning process.
Posted 12:36, 21 Feb 2010
If you are suffering from Erectile Dysfunction (ED) or male impotence and are desperate to take medicines to treat your disorder, it is of the utmost importance that you research the product or, get advice from a doctor about what medicine is right for you. Erectile dysfunction is the inability of a man to maintain an erection during sexual acts. This disorder can be very devastating and embarrassing for a man. Thanks to cheap cialis online, this is no longer a major issue.
Posted 07:23, 22 Feb 2010
Thanx for sharing this with all of us. Of course, what a great site and informative posts, I will bookmark this site. keep doing your great job and always gain my support. prom dresses wedding dresses prom dresses 2010 evening Dresses casual Dresses Cocktail dress formal Dresses holiday Dresses Celebrity Dresses
Posted 01:47, 23 Feb 2010
Prom Dress,Evening Dresses,Bridesmaid Dresses,Wedding, Formal Dresses Prom Dresses Bridesmaid Dresses cheap Prom Dresses Evening Dresses Need evening dresses,or gowns? Formal evening dresses from BCBG, evening gowns from formalgirl,Laundry and Nicole Miller. Wide Collection of Prom Dresses, Evening Dresses and Gowns, Cocktail Dresses, Wedding Dresses, Little Black Dresses, beaded dresses, ball gowns and Black Prom Dresses: Find Online fashionable prom dresses,homecoming dresses from top USA prom gowns designers, Evening dresses, sexy Tops , casual dress ,sexy Custom Dresses Elegant couture designer evening gowns, sexy dresses, inexpensive on sale prom dresses, bridesmaid dresses Simply Dresses is your source for cheap graduation dresses wedding dresses designer wedding dress
Posted 06:45, 27 Feb 2010
wedding dresses,wedding gowns,bride dresses,bridesmaids dresses,evening dresses,bridal gowns,flower girl dresses Wedding Gowns Formal Gowns Cocktail Gowns Find the wedding dress designer and wedding dress that's right for you! Browse dresses from Bridesmaid Gowns Evening Gowns View our selection of exquisite, handmade gowns and dresses for your wedding Wedding Dresses, Wedding Shoes and Wedding Accessories from wedding shop, the UK's finest collection of designer wedding dresses. Use the wedding dress and cheap wedding wedding dresses wedding shop
Posted 09:17, 28 Feb 2010
Post is nicely written and it contains many good things for me. I am glad to find your impressive way of writing the post. Now it become easy for me to understand and implement the concept. Thanks for sharing the post.casino gambling
Posted 19:09, 28 Feb 2010
Post very nicely written, and it contains useful facts. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement. Thanks for sharing with us. Acai
Posted 19:10, 28 Feb 2010
tiffany silvers tiffany silvers tiffany shop tiffany shop tiffany bracelet tiffany bracelets tiffany necklace tiffany necklaces tiffany jewellery tiffany jewellery tiffany jewelry tiffany jewelry tiffany uk tiffany uk tiffany rings tiffany rings tiffany earrings tiffany earrings
Posted 08:47, 5 Mar 2010
tiffany silvers tiffany silvers tiffany shop tiffany shop tiffany bracelet tiffany bracelets tiffany necklace tiffany necklaces tiffany jewellery tiffany jewellery tiffany jewelry tiffany jewelry tiffany uk tiffany uk tiffany rings tiffany rings tiffany earrings tiffany earrings
Posted 08:47, 5 Mar 2010
Pass4sure is an expert in providing the most valuable training materials for IT certification exams, equipped with accurate exam questions and verified answers, considerate & warmhearted service and complete safeguard measures. The Affiliate Program is a marketing strategy that Pass4sure adopts to assemble more dealers for propaganda and profit.The Most Popular Vendors List : CompTIA exam IBM exam Symantec exam IBM exam VMware exam EMC certification Oracle certification The Most Popular Certifications List : Oracle 11i certification SCJP certification HP ASE exam CCNP certification NCTS certification HP APS exam CCDP certification The Most Popular exams List : 642-515 BH0-006 JN0-342 SY0-201 310-200 642-515 642-892 642-812 VCP-410 350-040 646-671 642-736 1Z0-042 220-601 642-566 642-591 220-702 HP0-S21 642-691 642-062 350-050 Click Pass4sure to get more information!
Posted 00:55, 8 Mar 2010
Post very nicely written, and it contains useful facts. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement. Thanks for sharing with us. dermajuv reviews
Posted 14:21, 10 Mar 2010
Abercrombie Jeans Abercrombie Jeans Abercrombie Pants Abercrombie Pants Abercrombie Tees Abercrombie Tees Abercrombie Shorts Abercrombie Shorts Abercrombie Outerwear Abercrombie Outerwear Abercrombie Hoodies Abercrombie Hoodies Abercrombie Polo Abercrombie Polo Abercrombie Shirts Abercrombie Shirts abercrombie henleys crew abercrombie henleys crew hollister hollister hollister uk hollister uk abercrombie mens abercrombie mens abercrombie womens abercrombie womens Ruehl 925 Ruehl 925 Snuggie blanket Snuggie blanket tiffany rings tiffany rings tiffany engagement rings tiffany engagement rings tiffany wedding rings tiffany wedding rings tiffany necklace tiffany necklace tiffany sets tiffany sets tiffany bracelet tiffany bracelet tiffany necklace tiffany necklace tiffany pendant tiffany pendant tiffany earrings tiffany earrings tiffany accessories tiffany accessories tiffany charms tiffany charms links bracelet links bracelet links london bracelet links london bracelet friendship bracelet friendship bracelet links friendship bracelet links friendship bracelet sweetie bracelet charms sweetie bracelet charms links london charms links london charms links charms links charms charm bracelets charm bracelets links bracelet sweetie links bracelet sweetie charm links bracelet charm links bracelet sweetie bracelet sweetie bracelet links charms sale links charms sale Links Necklace Links Necklace Links Bangle Links Bangle Links Earrings Links Earrings Links Rings Links Rings Links Chains Links Chains links bracelet links bracelet links london bracelet links london bracelet friendship bracelet friendship bracelet links friendship bracelet links friendship bracelet sweetie bracelet charms sweetie bracelet charms links london charms links london charms links charms links charms charm bracelets charm bracelets links bracelet sweetie links bracelet sweetie charm links bracelet charm links bracelet sweetie bracelet sweetie bracelet links charms sale links charms sale Links Necklace Links Necklace Links Bangle Links Bangle Links Earrings Links Earrings Links Rings Links Rings Links Chains Links Chains tiffany jewelry tiffany jewelry links of london links of london
Posted 03:21, 11 Mar 2010
he online auction house must pay louis vuitton 200,000 euros, or $275,200, in damages plus 30,000 euros, or $41,300, louis vuitton bags for saleIn the case of any future violations, pay lv handbag a 1,000-euro, or about $1,400, louis vuitton outlet online to an LVMH spokeswoman. In a louis vuitton handbags on sale, eBay said it was disappointed but noted louis vuitton was awarded less than the 1.2 million euros, or $1.7 million, it sought.
Posted 01:08, 12 Mar 2010
Viewing 15 of 25 comments: view all
You must login to post a comment.