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 36 comments: view all
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
Natural slimming center offer 100% diet pills,slimming coffee,slimming tea,slimming underwear,slimming belt,slimming patch, natural breast enhancement and green coffee.Such as 100% originalmeizitang,2 day dietand http://www.nlslimming.com">lida daidaihua.
Posted 11:50, 12 Mar 2010

Titanium jewelry

has been an incontrovertible perfect gift idea. Here we have hundreds of cheap and discounted titanium jewelry including titanium rings,titanium bracelets,titanium necklaces,titanium earrings,titanium cufflinks and titanium wedding bands for your choice. All our titanium jewelry are perfectly polished, and shipped with classic black boxes and shopping bags.

Posted 16:08, 14 Mar 2010
By providing information on watches from all luxurywatch brands prada handbags herve leger 85% Off Bags and Wallets Christian Louboutin shoes Best Swiss Watcheswe help you explore the entire watch category - quickly and easily.
Posted 03:22, 15 Mar 2010
You know Replica Louis Vuitton ? And them you must know what is louis vuitton outlet store, you must so familiar with them, so convenient to you in daily life and shopping, But for the louis vuitton monogram canvas eva clutch m95567 with big name brand, you must afraid that can not afford it, there is no doubt to worry that, as we find that louis vuitton monogram canvas florin wallet m60026, so good and worth, now, thanks to the louis vuitton damier azur canvas french purse n61676, you know luxury items are so near to you, and which are no longer something that you always hesitate going for .Come on! louis vuitton monogram canvas galliera pm m56382 . You best collection.louis vuitton mens shoes pag58, I have to say that you must aware that the louis vuitton monogram denim canvas mini pleaty m95050 with big brand
Posted 05:30, 15 Mar 2010
A Links of london Lucky Catch Shell Charm is not only increasing your charm, but also bringing you good luck, it is said that shooting two birds is with one stone at Links london store.LuckyLinks of london give luck to you.
Posted 05:41, 17 Mar 2010
Links of london silver star spark chain make you feel confident and you will enjoy your right choice, Every piece of fine Links of london passes a rigorous inspection process before we offer to you. Come on to enjoy Links london.
Posted 05:41, 17 Mar 2010
Links london 4lover is an online store. From basics to classics, a unique classic a href="http://www.linksgiftstore.com">Links of london silver bead chain is the perfect gift for that special someone in your life. Links of london could help you feel every single moment of your happy life.
Posted 05:42, 17 Mar 2010
Links of london black leather silver chain are full of amazings, and this wonderfully playful and flexible black chain is sure to make a statement like no other just like Links london. When you choose Links of london black leather silver chain.
Posted 05:42, 17 Mar 2010
Discount prom dress prom dresses, cheap prom gowns,beautiful prom dresses short prom dresses and quinceanera dresses for sale, low price quinceanera dress and affordable wedding dress online shop. Sweet sweet sixteen dress,lovely prom dresses and prom dresses for your prom, we sale many discount prom dresses, sweet fifteen dress and quinceanera dress. wedding dress wedding dress discount wedding dress Bridal gowns discount wedding dresses discount wedding gowns wedding gown dress,quinceanera dresses prom dresses,prom gowns quinceanera gowns wedding dress, prom dress, bridesmaid dresss wedding dress blog and prom dress,beautiful pageant dress pageant dress Usa online wedding dress shop offers western western wedding dress and designer wedding dress, our best wedding dress,perfect wedding dress wholesale from wedding gown dress wedding dresses websites and designer prom dress will make you very pretty, pretty prom dresses and bridesmaid dresses is very gracy. Buy cheap prom dress, discount prom dress from best prom gown dress prom dress factory quinceanera dresses and retail prom dress,wedding dress,quinceanera dress.Buy wedding dress and prom dresses,discount prom dress and wedding dress factory from our wedding dresses factory. wedding dresses,wedding dresses prom dresses and beach wedding dress prom dresses prom dress, wedding dress prom prom dresses dresses quinceanera dresses,sweet 16 dresses at site sweet 16 dresses wedding dresses prom dresses prom dresses and gowns prom gowns quinceanera dresses Plus size wedding dresses bridesmaid dresses, prom gowns dresses prom dresses
Posted 08:43, 18 Mar 2010
Welcome to TiffanySilvers.us. Here you can find hundreds of cheap and discounted tiffany silver jewellery, which are perfectly polished and tiffany letters and 925 silver marked. If you are not familiar with tiffany jewelry, you can shop by the top navigation, showed as tiffany rings,tiffany bracelets,tiffany pendants,tiffany necklaces,tiffany earrings,tiffany cuff links and etc. For tiffany fans, you can shop by collections to save your time. We classified our tiffany jewellery not only by collections, like Tiffany 1837, Return to Tiffany, Tiffany Notes and etc. but also by designers' collections, such as Elsa Peretti Open Heart, Elsa Peretti Bean, Frank Gehry Fish, Paloma Picasso Loving Heart and so on. Hope our efforts can be more convenient for you to shop here.
Posted 14:50, 18 Mar 2010
Viewing 15 of 36 comments: view all
You must login to post a comment.