Page 2 of 5
Remember, when using Ant, the default behavior is to use the VM that started Ant to execute all the tasks; in the above scenario,
you may well have to use the fork attribute of the Java core task.
Furthermore, multiple instantiations of the TestCase class remain. Surely, if we want the test methods to be independent of each other, we would place them into different TestCase classes. So why multiple instantiations? Multiple instantiations allow you to isolate independent methods within the same
TestCase class, which is not always the desired behavior. Finally, too much technical code is required for circumventing the multiple-instantiations
scenario: I just want a test POJO (plain old Java object) class.
How does TestNG handle multiple instantiations?
TestNG does not require static block initialization and has a flexible configuration scheme for handling test classes based
on regular expressions and XML configuration files. TestNG does not instantiate the test class several times.
GroboUtils is an addition to JUnit that supports multithreaded unit tests (since the JUnit framework lacks such support). N. Alex Rupp gives an overview of GroboUtils in "Multithreaded Tests with JUnit" (java.net, August 2003). Although very useful, GroboUtils is not to my taste as it requires too much glue code to handle multithreaded unit tests.
How does TestNG handle multithreaded unit tests?
TestNG has multithreaded and parallel unit tests built in its core. You don't need to write specific code to handle multithreaded
unit tests as they are just a configuration of TestNG.
I would rather tag any method than be obliged to prefix methods with test, a task that JUnit requires. Admittedly, this is a minor point, but all IDEs now give you a view (like the Eclipse outline
view) that helps you quickly browse your methods to find the one you want—that is, if they are not all prefixed with the same
four letters. From a practical viewpoint, the Eclipse outline view is useless when you have dozens of test methods on a class
that start with the same four letters.
How does TestNG handle test method names?
TestNG uses Java annotations as specified by Java Specification Request 175 to tag methods for testing and grouping, and for expected exceptions, and so on.
TestNG is inspired by JUnit and also NUnit a unit-testing framework for .Net.
TestNG introduces new functionalities to unit testing such as:
Let's get started with TestNG. The remaining sections of this article introduce you to the TestNG features, starting with a basic first unit test: how to configure it and run it.
Archived Discussions (Read only)