JUnit or TestNG, that is the question


Up until now, I have commited with JUnit as standard testing framework for testing the agents. The main reason being that it was my first testing framework and, by that time, TestNG was less known. After some extensive experiments with TestNG I am really convinced this is a better option than Junit for my problems:

  • It has a better integration with FEST gui testing framework
  • I really find useful the repeating-test feature, that permits through a simple annotation, to indicate how many times a concrete test is going to be executed. This is significant whenever I suspect there is some race condition going on. Though it is not a valid evidence, it helps running one thing 100 times.
  • The grouping and test sorting feature is amazing. In JUnit, I have to start creating suites, dedicated clases for the same purpose. In TestNG, I have only to add a few annotations, and it runs as I want.
  • Being in Maven, TestNG can be automatically incorporated in the development. Eclipse has nice plugins for TestNG too. Before, only JUnit was so globally available.

There are other features which I have not found a concrete use for my framework, like the test parameterizing feature, but time will tell. For these reasons, I have decided to migrate all the IDK infrastructure to TestNG. This will imply that users running IDK tests will have to regenerate their code and make some adaptations, but, in general, changing a test from JUnit to TestNG is a matter of replacing one imports by others.