Jason van Zyl wrote:
Correct me if I'm wrong here Benjamin but I think he's talking about stating what tests you want to run, and how they are grouped declaratively. As a best practice don't use suites and come up with a way in Surefire to group things and avoid grouping of things in code.
Inter-class dependencies are one of TestNG's fundamental features; it's arguably the most important architectural difference between TestNG and JUnit. As Benjamin pointed out, they are declarative.
I think it would just be a practice for class to be self-contained, test one thing, and allow wiring up of sets/groups externally.
That's a good practice for unit tests, but TestNG is meant to support functional/integration tests. Unlike unit tests, which are meant to be isolated and test one thing, TestNG tests are supposed to test more than one thing together, and are therefore designed to inter-depend on one another.
It's a pretty significant philosophical shift; the TestNG guys wrote a whole book about it, blah blah blah. :-)
Dependent test methods http://beust.com/weblog/archives/000171.html Are dependent test methods really evil? http://beust.com/weblog/archives/000259.html Why unit tests are disappearing http://beust.com/weblog/archives/000319.html
If this model breaks down then maybe, as I've asked before, it makes sense to create separate plugins for the various test tools.
I'm still on the fence about that, but regardless I don't think this is a good candidate reason. Surefire has to handle this problem in the case of JUnit suites as well as TestNG suites; the only difference is that in JUnit this problem is less important because we think people mostly shouldn't write unit tests like that.
-Dan