[Hawkular-dev] JUnit and TestNG

John Sanda jsanda at redhat.com
Fri Jan 23 13:41:56 EST 2015


The decision was made a while ago to migrate from TestNG to JUnit. There was a PR[1] that migrated some of the integration tests to JUnit. I wound up rejecting the PR and keeping the integration tests in TestNG because it is not clear to me how JUnit supports some of the features that we have used and will continue to use with TestNG. Dependent methods is a good example. For the metrics aggregation tests in RHQ, there are tests for computing the 1 hr metrics, and there are tests for computing the 6 hr metrics. The 6 hr metrics test depends on the 1 hr metrics test. In JUnit the set up/tear down methods are considered part of the test fixture. In TestNG, they are configuration methods. This is a big difference because if a configuration method fails, then subsequent tests are skipped. This makes a lot of sense for integration tests. If I cannot create a connection to the database for example, then it is pointless to run the tests which rely on that connection.

My understanding is that there were a couple reasons for the change - 1) Arquillian has better support for JUnit than for TestNG and 2) JUnit is more up to date than earlier versions like 3.x (e.g., annotation driven). hawkular-metrics does not use Arquillian so I do not care about 1) and 2) is not much of a reason. Unless JUnit provides similar capabilities, I prefer to keep integration/functional tests in TestNG for hawkular-metrics.

[1] https://github.com/rhq-project/rhq-metrics/pull/101 <https://github.com/rhq-project/rhq-metrics/pull/101>


- John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hawkular-dev/attachments/20150123/2483fe5c/attachment.html 


More information about the hawkular-dev mailing list