Xunit

testing

tags:

XUnit is the family name given to bunch of testing frameworks that have become widely known amongst software developers. The name is a derivation of JUnit the first of these to be widely known.

The origins of these frameworks actually started in Smalltalk. Kent Beck was a big fan of automated testing at the heart of software development. To help him, and his clients, do this he would build a simple framework to organize and run unit tests. The focus was on making it easy for programmers to define the tests using their regular smalltalk environment, and then to run either a subset or a full set of tests quickly. Kent and his followers would run unit tests after every change to the system going through a rapid edit and test cycle in the Smalltalk IDE.

I ran into Kent at this time. I'd already done the same thing myself, but Kent's framework had a nice combination of absurd simplicity and just the right features for me. Basically he did a better job of it than I did so I just used his. In particular we used the framework on C3, where Ron Jeffries was also introduced to it.

I say 'it' but that's really a misnomer. There was no single kent-beck-smalltalk-unit-testing framework. Kent wants people to control their own environment, so he liked to have each team build the framework themselves (it only took a couple of hours), that way they would feel happy to change it to suit their particular circumstances - essentially it was really a Seedwork.

It was still unknown outside the Smalltalk community, so it's fair to give JUnit the credit for spreading the idea more. JUnit was born on a flight from Zurich to the 1997 OOPSLA in Atlanta. Kent was flying with Erich Gamma, and what else were two geeks to do on a long flight but program? The first version of JUnit was built there, pair programmed, and done test first (a pleasing form of meta-circular geekery). I heard about it and demanded a copy, which makes me one of the first alpha users. I felt free to change things I didn't like, sending some contributions back to Kent and Erich. If you're wondering who to blame for the fact that assertion messages are the first argument instead of following the java convention of putting optional arguments at the end....

JUnit also introduced the red/green bar progress indicator. At C3 we would color the whole window red once a test failed and green if they all passed. It was easy to see the window on the central build machine when you were integrating. JUnit introduced doing this as a progress bar, and thus added some new vocabulary to software developers.

JUnit took off like a rocket - and was essential to supporting the growing movement of Extreme Programming and Test Driven Development. I've seen a huge change of attitude towards testing in the last decade, and I think JUnit played a big role in that. By being small and simple it encouraged people to learn and use it. It also proved amenable to others extending it integrating it into tools. (Although I wish Sun would just bundle the whole thing into the JDK.)

As JUnit became more popular, other languages wanted one as well. I remember Michael Feathers putting together CppUnit for C++, which may have been the first port. Tons followed, nearly every language has at least one JUnit port. I suppose it was inevitable that it was also 'ported' back to Smalltalk as a real framework.

The ports vary. Some are line by line reworkings of the original JUnit, with little concession to the target language. The first version of NUnit even had a "isVAforJava" method which originated in special handling for Visual Age for Java. Others have been more sophisticated: NUnit 2.0 was praised by Anders Heljsberg for its use of attributes in C# - experience that has come back to the Java community and JUnit itself as Java developed annotations.

With all of these ports cropping up, Ron Jeffries decided to keep a list of xUnits on his website. It's still the main place to go to if you want to find an xUnit for your current language. (Ron also has a copy of Kent's original paper on the smalltalk patterns.)

Share: