Interview and Book Excerpt: Hani Suleiman & Cedric Beust on TestNG
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 del.icio.us 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.
Mocks and Stubs
This allows to generate a random User (for example) Value Object like this:
UsurperGenerator<User> userGenerator = new UsurperGenerator<User>(User.class);
//GENERATE ONE INSTANCE
User user = userGenerator.generateUsurper();
//GENERATE A LIST OF INSTANCES
List<User> userList = userGenerator.generateUsurperList(3);
There are many other features, like automatic stubbing of DAO methods. Check it out!