Java News from Monday, February 14, 2005

Cedric Beust has released TestNG 2.1, an open source ( testing (unit, functional, and integration) framework based on annotations. New features in this release include nvocationCount, successPercentage, timeOut, and dependsOnMethods. TestNG is released under the Apache Software License. Java 1.4 or later is required.

TestNG is intended to replace JUnit, but mostly the problems that led Beust to create it aren't ones I've encountered, with the single exception of run-once initialization code. In fact, some of the problems he cites strike me as features, not bugs. For instance, I consider it essential that one test method not depend on another. Genuine tests (as opposed to shared initialization code) should be able to be run independently and in any order. However, perhaps this is a distinction between functional and unit tests. I seriously question the decision to move some of the configuration out of the code and into separate XMl files. As much as I love XML, the difficulty of keeping multiple files in sync to make tests run is just too much of a pain. One of the innovations of JUnit and the important insights of Beck and Gamma was that programmers like writing code, and therefore tests that are pure code are more likely to be written and maintained in the first place.

Beust is right that JUnit's assert methods put the error message string in the wrong place. It should be the last argument, not the first. (In general, optional arguments should come later.) However, his suggested fix goes too far by providing both failure messages and success messages. Successful tests should generate no visible output. Otherwise, it's too easy to miss the one failing test in a sea of success messages. Even if you do realize a test has failed, sifting through the success messages looking for the failed test is a pointless exercise. A test suite should just tell you about the tests that have failed and need to be fixed. I don't need to see details from tests that have passed.

I think this problem has been corrected in the actual release, but the poorly organized documentation makes it hard to be sure. One of JUnit's strengths was its documentation and evangelization. There's no decent equivalent to "Test Infected" explaining how to start using TestNG. Instead, the documentation reads like random jottings in a developer's notebook. Some parts are documented very well, and some not at all. Which parts are which seems to have more to do with what the developer was interested in writing about than what a potential user is interested in learning about. There's no one place a new user can jump in and start learning about TestNG. So, while there might be some good software here, it's too hard to find.

Cenqua has posted FishEye 0.10, a $999 payware tool for viewing CVS activity. I've been using FishEye lately as part of my work with the Jaxen Project. As well as drawing graphs of activity, it lets you see who'd committing what when to CVS, what individual committers have been up to, what's going on in different branches, what's happened to particular files, and so forth. It's not essential, and I doubt I'd pay for it if Cenqua hadn't given Codehaus a free copy. XOM doesn't use it, and I haven't missed it there. However, FishEye is a nice tool that's a definite improvement over standard CVS and ViewCVS.

Derrick Oswald has released the HTML parser 1.5, a free (LGPL) class library for parsing "real-world HTML." This release adds support for proxies, passwords and cookies. It also provides a new API for filters.

Sebastiano Vigna has released version 4.4 of fastUtil, a collection of type-specific Java maps and sets with a small memory footprint and faster access and insertion. The classes implement their standard counterpart interfaces such as java.util.Map and can be plugged into existing code. However, they also contain type-specific methods. For instance, the CharList class has not only the usual add(Object o) method but also an add(char c) method. Version 4.4 adds a new package for high-performance I/O of objects, arrays, and iterators. fastUtil is published under the GNU Lesser General Public License (LGPL).