Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
TDD Tip: Leave a Broken Test

How do you know where to start when you sit in front of your screen in the morning? Half of the developers population will probably start with a cup of coffee, some will visit Slashdot or Channel 9 (that's me!). There is, however, a breed of developers, that starts by checking out the fresh code and gets to hacking right away. If you are this kind of developer, this little tip is for you. Procrastinators already know what to do.

How often do you as yourself a questions like: what do I start with today? Or what was I working on yesterday? How often do you browse your post-it notes to pick the next task and you're lost? If you often find yourself in situations like these, there is a very helpful tip I learned from Kent Beck's Test Driven Development: By Example. The trick is: leave a broken test. The last thing you do before you turn off your screen is to write a test that fails. Name it appropriately so that you know what behavior it tests and make it fail. Write a failing assert or just leave Assert.Fail call. When you sit in front of your IDE next morning and start with running your tests, you will have a clear sign of where you finished yesterday and what you should implement next. This is especially useful to have a test like this on Monday. I don't work during the weekends, so I always find it very helpful to restore the context in a couple of seconds.

There is a little issue in this method and this issue is teamwork. By no means, don't check in your failing test as others may think it is... well, a broken test. A bug. Something they need to fix ASAP (if you have loose code ownership). They will either blame you (not very likely but possible) or fix it themselves. Either way, leaving a broken test committed into the source code repository is clearly not a good idea. If you have any comments or ideas about this tip, please share!


Posted 04-05-2007 8:28 AM by Marcin Hoppe
Filed under:

[Advertisement]

Comments

Derik Whittaker wrote re: TDD Tip: Leave a Broken Test
on 04-05-2007 7:11 AM

Marcin,

This is a very good suggestion.  I know I leave notes for my self every day on where to start back up the following morning (of course i have to do my daily moring surfing first :)).

Derik

Billy McCafferty wrote re: TDD Tip: Leave a Broken Test
on 04-05-2007 4:59 PM

That reminds me of a presentation I was giving last year.  As I often do, I had left a broken test for the exact reason you've stated.  I was giving a presentation, using my project work as examples and emphasizing the point that you should never have a broken unit test when you check all your code in.  To show this, I confidently opened NUnit, ran the tests, and...wham...red bar.  A couple of chuckles later, I let them all know that it was broken intentionally for when I got back to work.  I think they inferred that I was trying to pass a bug off as a "feature."

buy stendra online wrote re: TDD Tip: Leave a Broken Test
on 02-15-2013 4:20 PM

yTFY7G Thanks-a-mundo for the article post.Really thank you! Awesome.

Clomiphene 50 mg wrote re: TDD Tip: Leave a Broken Test
on 02-28-2013 7:16 AM

qiUsmQ Im obliged for the blog post.Much thanks again. Really Cool.

social bookmarking service wrote re: TDD Tip: Leave a Broken Test
on 04-19-2013 1:50 PM

zaqoW0 Muchos Gracias for your article.Much thanks again. Awesome.

social bookmarking service wrote re: TDD Tip: Leave a Broken Test
on 06-05-2013 7:22 PM

jpJocZ Wow, great blog article.Thanks Again. Cool.

link building team wrote re: TDD Tip: Leave a Broken Test
on 10-01-2013 1:10 AM

ijGCIe Great, thanks for sharing this post.Thanks Again. Really Cool.

link building wrote re: TDD Tip: Leave a Broken Test
on 07-18-2014 5:38 PM

EnNHQk Great, thanks for sharing this post.Really thank you! Awesome.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)