Facilitating the spread of knowledge and innovation in professional software development



Choose your language

InfoQ Homepage News Interview and Book Excerpt: Hani Suleiman & Cedric Beust on TestNG

Interview and Book Excerpt: Hani Suleiman & Cedric Beust on TestNG

Bookmarks recently sat down with Hani Suleiman and Cédric Beust the authors of Next Generation Java Testing: TestNG and Advanced Concepts to discuss the book and their thoughts about testing in general. InfoQ is also pleased to offer an excerpt from chapter 2 of the book, "Mocks and Stubs".

TestNG started as an experimental toy project. The main motivation was that despite using JUnit for years, there were still a lot of concepts and approaches used by JUnit that I didn't feel comfortable with. The more I investigated, and the more I disagreed with some of its core philosophical design decisions, such as reinstantiating your class before each method invocation (thus forcing me to use statics if I want to maintain state between invocations) or not allowing me to create dependent tests, which are crucial for functional testing.

Overall, I just found that JUnit was doing great in the area of unit testing but was lacking in other places required by any kind of functional or acceptance testing.

Back then, I was also involved in the annotations JSR and it occurred to me that annotations would be a good fit to mark test methods.

Finally, the last piece in the puzzle came from a web site with the strange name of that introduced this bizarre new concept of "tags". It occurred to me that it would be neat if I could tag my test methods and then be able to invoke any arbitrary group of them without having to recompile anything. I renamed these tags "groups" and I realized that they would be a great match for annotations as well.

With these ideas in mind, I set out to create TestNG 1.0 almost four years ago and I published it just for fun and to get some feedback.

Read more of InfoQ's interview with Cedrick Beust and Hani Suleiman

We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Free facials?

    by Michael Neale,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    For the first 100 copies sold? (sorry, couldn't resist).

  • Mocks and Stubs

    by Pierre-Antoine Grégoire,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    If you need to create Random Value Objects on the fly for your tests, consider Usurper (Shameless self-publicity).

    This allows to generate a random User (for example) Value Object like this:

    UsurperGenerator<User> userGenerator = new UsurperGenerator<User>(User.class);
    User user = userGenerator.generateUsurper();
    List<User> userList = userGenerator.generateUsurperList(3);

    There are many other features, like automatic stubbing of DAO methods. Check it out!

  • free chapter

    by serge ----,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I just read the free chapter, liked it so much that I decided to buy the book.


Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p


Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.