InfoQ

News

TestNG concluded more suitable for large-scale testing than JUnit 4

Posted by Floyd Marinescu on Sep 05, 2006 03:00 AM

Community
Java
Topics
Software Testing,
Build systems
Tags
TestNG,
JUnit,
Testing
Andrew Glover compared TestNG and JUnit 4, taking a look at some features that TestNG has over JUnit 4.  Andrew quickly takes the position that TestNG is better for large scale testing, despite JUnit 4's recent addition of annotations and "dramatically relaxed structural rules for test case authoring."   The three killer features that TestNG has over JUnit 4, according to Andrew (summarized here), are:
  1. Flexibility. TestNG doesn't require public init() methods or static test fixtures.
  2. Dependency Testing. In JUnit, for tests that fail, they have an inconvenient consequence: every subsequent dependent test also fails.  TestNG models the notion of dependencies between tests so that  tests dependent on the failed one will be skipped, allowing the rest to proceed. "TestNG's trick of skipping, rather than failing, can really take the pressure off in large test suites."
  3. Re-Running failed tests. TestNG notes which tests failed and allows you to re-run them instead of all of them - handy on large test suites.
  4. Parametric Testing.  In JUnit, if you want to vary the parameter groups to a method under test, you are forced to write a test case for each unique group. You can use FIT to drive tests with tabular data, but TestNG provides a similar feature right out of the box. You can even feed in complex objects with some additional configuration.
The author conludes:
As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands. Each framework has its strengths, and there's nothing stopping you from using both in concert.
Recently, build server vendor Zutubi blogged about how the the dependency test feature in TestNG is a good solution for managing tests with occasionally available external dependencies. Back in May, the GlassFish project quality team compared both frameworks and also chose TestNG as the main test suite for Sun's GlassFish testing.  TestNG 5 was released on July 20th.     InfoQ Chief Architect Alexandru Popescu is the co-founder of TestNG 5 along with Cedric Beust.

No comments

Reply

Exclusive Content

Rationalizing the Presentation Tier

Thin client paradigm characterized by web applications is a kludge that needs to be repudiated. Old compromises are no longer needed and it's time to move the presentation tier to where it belongs.

Agile Project Management: Lessons Learned at Google

In this presentation filmed during QCon 2007, Jeff Sutherland, the creator of Scrum, talks about his visit at Google to do an analysis of Google's first implementation of Scrum.

AtomServer – The Power of Publishing for Data Distribution

In this article, Bryon Jacob and Chris Berry introduce AtomServer, their implementation of a full-fledged Atom Store based on Apache Abdera, which is now available as open source.

An Introduction to Virtualization

It is easy to think that virtualization applies only to servers. In reality the recent resurgence of the concept is also being applied to networking, storage, and application infrastructure.

REST Anti-Patterns

In this article, Stefan Tilkov explains some of the most common anti-patterns found in applications that claim to follow a "RESTful" design and suggests ways to avoid them.

Choosing between Routing and Orchestration in an ESB

In this article, Adrien Louis and Marc Dutoo discuss the differences and relative merits of using orchestration vs. routing in a typical ESB setup, and discuss various implementation options.

Enterprise Batch Processing with Spring

Wayne Lund discusses batch processing, Spring Batch objectives and features, scenarios for usage, Spring Batch architecture, scaling, example code, failures and retrying, and the future roadmap.

User Story Estimation Techniques

Developer Jay Fields draws on his experiences as a ThoughtWorks consultant to describe effective user story estimation techniques.