Skip to main content

Test-Driven Development

Test-Driven Development is a paradigm shift with its novel approach to software development. It puts the fun back in development, while improving quality and end-user satisfaction.

Unit testing is one of the cornerstones in agile development. A comprehensive suite of automatic tests for your source code generates many benefits. Your confidence in modifying the source code will skyrocket because you know that if you unintentionally break something the tests will catch it.

But this is just the first step. By writing a test for a new feature before the actual implementation, you are set up to reap additional benefits. For most developers uninitiated in this technique, it sounds counterintuitive and like a big waste of time. Still, this is the way that I have developed software for the last couple of years, and I really can't see myself writing a substantial amount of code not using this technique.

The technique I described above is called Test-Driven Development (TDD) and is steadily gaining popularity. It stems from one of twelve extreme programming practices, and many friends and colleagues to whom I introduced it swear by TDD today. The main benefit gained from a test-driven approach is that you are approaching the solution from the top, from the user’s perspective.

Too many potential killer apps are destroyed by programmers who develop bottom up. When it comes to designing the interface (like a GUI or API), they find themselves tied down to their early ill-informed low-level design choices. By doing TDD you will let the requirements drive the development. As a positive side-effect it is a thrill to develop software this way, you are always focused on reaching one specific goal, usually not that far away. It is difficult to lose focus on what you are out to accomplish in the source code while trying to get a test to pass.

Automatic tests can also be used to specify programming assignments. You hand your colleague a set of tests that lack implementation and ask him to implement the required classes so that the tests will pass.

So how do you do this in practice? Well, if I were you I would head straight over to xUnit’s Wikipedia entry where free tools are available for almost any language/platform. For .NET development, nUnit is the testing framework of choice. Good luck with your tests!

Comments

Popular posts from this blog

HOWTO: GTD with Google Docs & PocketMod

Take control of your unwieldy to do-list by combining Google Docs and PocketMod. With the system described here you will always be ready to take notes, and never run the risk of losing an idea! Update (July 30, 2009): Now using a Google Docs template. I use a subset of GTD (" Getting Things Done ") by having a digital copy of my next actions, sorted by context (@Home, @Office, @Shopping, @Computer, etc.). This lets me easily look up what I need to do, depending on where I am. However, a digital copy is not very useful by itself, since it is not accessible when I am offline. Putting it in my PDA is not ideal either, since the overhead of adding a new note is too big (turning on the device, opening the right application, having it recognize my handwriting). That's why I print out my to-do list on paper once a week and carry it in my pocket. It's the ideal way of accessing and editing tasks. Before I print out a new list I spend a minute or two copying the edits from my

HOWTO: Fix a Broken Laptop Lid for $1

A few months ago my laptop lid's hinges gave up and my lid kept falling over. I will show you how I fixed the problem in five minutes by using materials for $1. But first some background info. At first, I assumed there would be a quick and simple fix to this common laptop problem. My laptop is an Evo N800v. HP has bought Compaq since I purchased the computer so that's where I'm supposed to turn for help. I was kind of startled to hear that HP support wanted $500 for fixing the broken hinges - presumably they intended to replace the entire lid. Obviously, shelling out $500 for fixing a 6 year old laptop is not the way to go, so I started to look for alternative solutions. First, I disassembled the laptop numerous times, trying to make the hinges more sturdy (that's spelled S-U-P-E-R-G-L-U-E). Anyway, that didn't help. Option number two was to do something similar to what user xrobevansx did on instructables.com . Basically he bought a lid support in a hardware store

Reading on Paper vs. on Screen

One of the basic premises behind FeedJournal is that it's better to read text on paper than on a screen. While it might not sound like a bold assumption, it still is an assumption and as such worth to examine deeper. Today, office workers and many other professionals are required to focus their eyes on a computer screen during most of their work day. Many of them continue to use the computer at home. FeedJournal was created with many goals in mind; one of them is to release you from the screen while enabling you to read the content you love. You shouldn't have to spend more time reading off a screen, just because you want to access fresh and relevant content. Recent research has found that reading a longer text on paper is 25% faster than reading the same text on a computer screen. At the same time, reading comprehension and article overview are improved. Although screen resolutions have increased and font rendering technologies such as ClearType make it much easier to rea