TestNG Makes Java Unit Testing a Breeze
By Filippo Diotalevi2005-03-22
Wrapping up
In this article, I've offered a quick and practical introduction to TestNG, with the aim of showing how you can start writing unit tests now. However, it isn't a complete reference manual. There are a lot of other interesting features of TestNG that can be very useful:
• It's possible to pass arguments to test and configuration methods, declaring them either with annotations or in the XML configuration file.
• You can run good old JUnit tests under TestNG using a "compatibility mode."
• It's possible to establish dependencies among test groups, deciding their order of execution.
A look at TestNG's documentation (see Resources) is necessary to exploit all the potentialities of this framework.
All these features, together with the adoption of Java annotations to define tests, make the whole testing process much more simple and flexible. There are only a few rules that you must obey to write tests; beyond these, you are absolutely free to choose the testing strategy you prefer.
What clearly emerges while using TestNG is that this framework is already a good choice for writing unit tests, and that it is, by design, simple to integrate with other libraries and tools, so its future development can bring developers some interesting news. A new path has been forged.
Tutorial Pages:
» Try this testing framework for its advances over JUnit
» About the code
» TestNG quickstart
» Defining test groups
» Configuration methods
» Exception checking
» Wrapping up
» Resources
First Published on IBM DeveloperWorks
