TestNG Is A-OK



Email    print   
July 15, 2006 —  (Page 1 of 3)
Test-driven development (TDD)—where you write the tests before you write the code, and run the tests every 10 minutes or so as you’re coding—is something everyone should be doing. Not only does TDD make the code go together faster with fewer bugs, but it also takes a lot of tension out of day-to-day programming tasks. The worst-case scenario when you introduce a bug is throwing away the last 10 minutes of work.

To practice TDD, however, you need an easy-to-use automated test environment, ideally one that can be customized for the work at hand. For example, you may want to run only a small set of localized tests every 10 minutes, with a more thorough, but slower, test pass every hour or so.

JUnit has been the standard for this sort of testing, but JUnit has its problems. It’s difficult to set up JUnit to run several disconnected tests in a single run, for example. There’s also no easy way to chain tests (where a test depends on the success or failure of a previous test—JUnit test methods each run in their own objects, even if they’re declared in the same class, so they can’t easily interact with one another). You also can’t get fine control over which tests run, so it’s difficult to customize a test suite to the code you’re working on right now.

I also have mixed feelings about JUnit’s insisting on putting test methods in special test classes. On one hand, the separate-class approach lets you exclude the tests from the shipped code. Just omit the .class files. On the other hand, I get nervous when the tests and the code aren’t in the same class definition. It’s too easy to not add a test when you add new code.

There is an alternative to JUnit that fixes these problems: TestNG (www.testng.org), a test framework written by C?dric Beust and ported to Java 1.4 by Alexandru Popescu. (There's a testing tutorial at membres.lycos.fr/testng.)




Pages 1 2 3 


Share this link: http://sdt.bz/29435
 
Most Read Latest News Blog Resources

Add comment


Name*
Email*  
Country     


  • Comment
Loading




close
NEXT ARTICLE
TestNG 5.0 Smoothes Out Annotations
TestNG’s ability to organize thousands of unit tests has improved with the release of version 5.0 in late July Read More...
 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 

Download Current Issue
FEBRUARY 2012 PDF ISSUE

Need Back Issues?
DOWNLOAD HERE

Want to subscribe?


 
blogs tab
Are you at risk for burnout?
Burnout is a severe problem and it can strike at any time. Here's how to tell if you are nearing the edge.
02/09/2012 02:16 PM EST

Agility, mom, and apple pie
If we're to evaluate the state-of-the-art in software development, we should start with the values espoused in the Agile Manifesto.
02/07/2012 11:57 AM EST

RIM woos developers with free tablet
How do you get more apps ported to the BlackBerry PlayBook? By giving every developer a free tablet, of course!
02/04/2012 01:57 PM EST

GitHire: Use Headhunters to Find Your Perfect Programmer
Are you a hiring manager tired of scouring the job boards? Check out this new service that will find 5 people interested in your jobs.
02/03/2012 12:17 PM EST

Facebook claims hacker cred
Facebook's SEC S-1 filing form includes a short essay on the Hacker Way by Mark Zuckerberg himself.
02/02/2012 08:26 AM EST

Ryan Dahl steps down
Ryan Dahl, creator of Node.js, steps back from his position as gatekeeper for the project.
02/01/2012 04:58 PM EST

 
Events calendar tab
2/13/2012 to 2/16/2012
Santa Clara
TechWeb

2/26/2012 to 2/29/2012
San Francisco
BZ Media

2/27/2012 to 3/2/2012
San Francisco
RSA

3/4/2012 to 3/7/2012
Las Vegas
IBM Tivoli

3/5/2012 to 3/9/2012
San Francisco
TechWeb