Archive for December, 2007

JUnit vs. TestNG

Friday, December 7th, 2007

The problem: We have several XML transformations, which we want to test with several inputs each. The tests are done by running the transformation on a source XML file and comparing the result with an expected XML file (using XMLUnit’s Diff class). These XMLs are stored in directories in the file system, where each such directory contains the input file, the expected result and info of which transformation to use them against.

I want each directory to be treated as a separate unit test, but I don’t want to actually write a separate test method for that. Thus the XML test will be well integrated with the rest of the unit test of the system and I don’t have to develop separate reports and other management stuff for them.

I couldn’t find anything like that for JUnit, other than the advise to read JUnit’s source code and try to figure out where to hook my changes. But I also found this blog entry, discussing JUnit extensions. Yes, I know, his needs were different than mine. Anyway, I decided to give TestNG a try, because I’ve also considered it before for a different project. And guess what I found! They have a nice little feature, called “factories,” which allow you to dynamically generate test cases. Just what I needed.

There are TestNG plugins for various IDEs, including Eclipse, and it is supported by Maven. So, it seems TestNG is the right answer for this situation.

Paul Graham predicted iPhone?

Monday, December 3rd, 2007

I was rereading the essay “The Other Road Ahead” from “Hackers & Painters” and I was quite surprised by the following note (it’s number 14):

If the Mac was so great, why did it lose? Cost, again. Microsoft concentrated on the software business and unleashed a swarm of cheap component suppliers on Apple hardware. It did not help, either that suits took over during a critical period. (And it hasn’t lost yet. If Apple were to grow the iPod into a cell phone with a web browser, Microsoft would be in big trouble.)

This was back in 2004, mind you! And Apple announced iPhone in January 2007. “The Other Road Ahead” was originally published in September 2001, and is missing the part between the parentheses, but it turned out that Apple announced iPod one month later.

Most impressive.