Discussions

In "JUnit V TestNG: Managing external dependencies," the founders of Zutubi discuss how JUnit and TestNG both manage reliance on external resources, with TestNG having a huge advantage due to some annotations features. How do you solve resolution of external dependencies with either framework?
In JUnit3, they describe two possibilities: one is having an assertion that looks for the resource and fails upon not finding it, which tends to yield large stack traces; an alternative is to use a decorator that checks the resource, but this has the disadvantage of being fairly invasive for every test.
In TestNG, the @Test annotation can include dependencies on other methods; if the other methods fail, then tests with those dependencies won't run. This makes for a more clean implementation and runtime, compared to the JUnit 3 implementation.
From the post:

Given these results, I certainly prefer the TestNG solution. The output is clear and the association of dependencies to tests is defined with each test case and on a per test basis, not on the per class basis as with JUnit. Now if only I was using TestNG. Maybe it is time to run the JUnitToTestNGConverter?
I am curious to know if other people run into this issue? And if so, how do you solve it? Maybe you do one of the above, or have written custom annotations or extended JUnit. Please let me know, I would love to hear about it.

I also find Test NG features for managing large test suits (dependencies, groups) give it an edge over JUnit.

Agreed. I also was suprised that the article didn't talk about this, especially since it seemed primarily to be talking about the major features in TestNG that are not present in JUnit 4.x.
Groups are my #1 feature in TestNG. The fact that I can label individual tests as being fast/slow, dependent on an environment etc. and not have to create custom suites to manage all this makes thing so much easier.
-Tim Fennell
Stripes: Because web development should just be easier.

Ooops, I guess I should have read the article first ;) I didn't think there could be two JUnit vs. TestNG articles in as many days, but apparently there are.
I thought the post was about this new DeveloperWorks article which is also doing a JUnit vs. TestNG comparison:
http://www-128.ibm.com/developerworks/java/library/j-cq08296/
-Tim Fennell
Stripes: Because web development should just be easier.

TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations technology projects - with its network of technology-specific websites, events and online magazines.