Free Newsletters
Technology & Business Daily

InfoWorld
Log-in | Register

Test before you leap into development

Take a test-driven approach, and your engineers will better design software and engage in risk-free refactoring

By Jon Udell  
August 01, 2003
 

Programmer and author Dave Johnson shared an anecdote on his Weblog last year about what happened when his 5-year-old son walked up behind him while he was coding. "He saw the JUnit green bar on the screen," Johnson reports, "and said 'Dad, you did good.' " There's more to this touching father-and-son moment than meets the eye. The idea that software development can proceed by tackling a sequence of small tasks -- the successful completion of which is evident even to a child -- is fueling a groundswell of interest in the so-called "xUnit" testing frameworks (see sidebar) and in a companion work style called "test first" or "test driven."

Free IT resource

Open Source Business Conference (OSBC) May 22-23, 2007

Sponsored by OSBC

Free IT resource

Virtualization Insights from Top Experts - Learn how virtualization gets real!

Sponsored by Dell

Practitioners of TDD (test-driven development) typically align themselves with one or another of the "agile" methodologies -- most notably, XP (eXtreme Programming) -- and use software tests in an unconventional way. Historically, IT has thought that the people who write code can't, or shouldn't, be responsible for testing it. In many ways that's still a good rule of thumb. QA (quality-assurance) testers will always be needed to find problems -- poor user interfaces, slow response under load, or incorrectness -- that programmers have overlooked. TDD doesn't put them out of a job.

"If you're the head of QA and you hear that your developers are working test-first," says Ward Cunningham , an independent consultant pioneering the approach, "you should think, 'Good for them -- now we can focus on the truly diabolical tests instead of worrying about these dead-on-arrival problems,' " (see "XP pioneer stumps for test-first programming").

TDD solves a different set of problems. It does so by proposing that before you write any nontrivial piece of production code, you write tests that the code will at first fail, and then when written correctly, will pass. TDD advocates say this approach has two major benefits.

First, because the tests embody specific uses of the yet-unwritten software, they will help tease out the design of the software, complementary to other techniques such as requirements specification and modeling. Second, the tests create a safety net, enabling the programmer to engage in the risky but necessary practice of refactoring -- continuously reorganizing the code -- without fear of breakage. One of XP's tenets is that change is the only constant. As the business environment evolves, so do the requirements it imposes on software. Although software is in theory perfectly malleable, in practice we are often afraid to change it. TDD seeks to reduce that fear by controlling the risk associated with change.

Serious practitioners of TDD write a lot of tests. Kent Beck, author of Test Driven Development: By Example, notes that one project done in the TDD style amounted to 250,000 lines of production code and an equal number of lines of test code. Others confirm that this one-to-one ratio is typical. Can this really be economical?


Continued
1 | 2 | Next Page » 



 


 
Jon Udell is lead analyst and blogger in chief at the InfoWorld Test Center.

  More of Jon Udell's column
  Jon Udell's Weblog

Newsletter Check out all of our free newsletters!
Enter e-mail address:




 

TOP NEWS:


»  Troubleshooting tool for Java offered
Sun's Java VisualVM open-source technology views apps while they run on a JVM and is billed as all-in-one solution

»  Python backing eyed for NetBeans
Scripting language capabilities of the open-source IDE continue to expand

»  Microsoft sets Windows XP SP3 automatic download for Thursday
The latest service pack for Windows XP will be pushed to Automatic Update at 7a.m. EDT on July 10

»  Real Software, Veryant bolster dev tools
RealBasic, Cobol apps platforms get improvements

»  Microsoft sets hosted-services pricing, irks partners
By offering 38 percent discount to customers who buy entire hosted business productivity suite, Microsoft undercuts partners selling similar services

»  Adobe readying new mashup tool for business users
Mashup interface code-named 'Genesis' will open up desktop 'workspace' combining business application data, documents, analytics, and instant messaging




5 Things You Need to Know About Storage Virtualization
This Webcast feature insights from various InfoWorld articles, as well as primary research conducted by InfoWorld and sister company IDC to better understand demand drivers, challenges and opportunities provided by storage virtualization, as well as other flavors or approaches to virtualization Sponsor: HP

»  Click here to view this Webcast
  The Silver Lining: Cloud Computing
This IT Strategy Guide digs deep into cloud computing helping put you ahead of the curve on this hot topic. It explores the differences between cloud computing, grid computing and utility computing and then helps you see where and how each applies to your business. Sponsored by Box.net

»  Click here to download now

- Special Advertising Partners -
WHITE PAPERS
 

» Technology White Papers Library

Technology White Papers by Topic

Technology White Papers E-mail Alert

Find out when the latest white paper is available:
 
 
INFOWORLD MARKETPLACE
 
» BUY A LINK NOW
 
SEE ALSO
• Rational readies Microsoft app dev tools
• CTO Forum: Taking programming to the extreme


FIND PRODUCTS AND COMPANIES
» COMPLETE PRODUCT GUIDE



TECHNOLOGY INDEX
• Applications
• Application Development
• Security
• Networking
• Wireless
• Platforms
• Hardware
• Data Management
• Storage
• Web Services
• Business
• Telecom
• Professional Services
• Standards

TECH WATCH 


What's the 411 on GOOG-411?
Just as Google has become synonymous with "performing a Web search," 411 is understood to mean "information" -- as in "what's the 411?" I was thus surprised to discover, from a billboard, no less, that the king of search is taking on the ...

Apple HTML source reveals 'iPhone Extreme'
"This one's a stretch..." reports AppleInsider. Um, yeah. Reporting on HTML code sightings of product names could be called a stretch, but iPhone Extreme has a ring to it. Now, that sounds like the product Apple should have released first, rather ...

COLUMNISTS

Unified under law
Ephraim Schwartz's Column and Blog (InfoWorld) - In the litigious world we live in, deploying a unified communications platform in your enterprise could...
» MORE COLUMNISTS

MORE INFOWORLD BLOGS


Open Sources 
Product Management
When I joined MySQL four years ago, there was quite a lot of debate about product management. We didn't actually have ...

Zero Day 
Botnet herders tending smaller flocks
New research backs up the theory that botnet operators are keeping their networks smaller in a continued effort to keep ...



• Advice Line
• Database Underground
• The Deep End
• Enterprise Mac
• Geeks in Paradise
• Grid Meter
• The Gripe Line
• InfoWorld Daily
• Inside IT
• IT Troubleshooter
• ITXtreme
• Open Sources
• ProdBlog
• Real World SOA
• Reality Check
• Security Adviser
• SMB IT
• The Storage Network
• Tech Watch
• Virtualization Report
• Zero Day

ADVERTISEMENT


RESOURCE CENTERadvertisement 

GOVERNMENT IT & POLICY
'If you don't go after the network, you're never going to stop these guys. Never.'
From the State Department, All the News for Inquiring Minds
TechPresident, the Internet Citizenry's New Consensus Taker



Sponsored Technology Links

 
 
 HOME  NEWS  BLOGS  PODCASTS  VIDEOS  TECHNOLOGIES  TEST CENTER  EVENTS  CAREERS   About | Advertise | Awards | RSS | Contact Us 

Copyright © 2008, Reprints, Permissions, Licensing, IDG Network, Privacy Policy, Terms of Service.
All Rights reserved. InfoWorld is a leading publisher of technology information and product reviews on topics including viruses,
phishing, worms, firewalls, security, servers, storage, networking, wireless, databases, and web services.

CIO :: ComputerWorld :: CSO :: Demo :: GamePro :: Games.net :: IDG Connect :: IDG World Expo
Industry Standard :: IT World :: JavaWorld :: LinuxWorld :: MacUser :: Macworld :: Network World :: PC World :: Playlist