Unit testing software always requires a testing framework. Based on his Smalltalk experiences, Kent Beck developed JUnit together with Erich Gamma. Nowadays it is one of the standard frameworks with a lot of extension modules. JUnitX is one of those modules, allowing to test private and protected Java classes, methods and variables.

JUnit and JUnitX are supported in Together, the leading UML-modelling tool by the module XPTest. XPTest also provides test class generation and test maintainance features.

To get started with Unit testing, read the article Test Infected of Kent Beck or look through the example below. If you want to get the real stuff, read the new tutorial on Advanced Java Testing.

For the rest of you, here is an introductionary example showing you how to use JUnit and JUnitX and what are the main differences:

JUnit Example

1. Create a production class


 
2. Create a test class



 
3. Create a test proxy
(not possible with JUnit)


4. Create a test package



 
5. Run the Swing UI


 
6. Run the Text UI


JUnitX Example

1. Create a production class



 
2. Create a test class


 
3. Create a test proxy


 
4. Create a test package


 
5. Run the Swing UI


 
6. Run the Text UI


Download the example sources.

© 2001 A. Heilwagen