testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

dependsOnGroups fails to apply in some case (possibly when on a subclass with the test on the parent?) #959

Open mattsheppard opened 8 years ago

mattsheppard commented 8 years ago

Attached is a maven project with test cases which should occur in a specific order, which I think reveals incorrect behavior in terms of TestNG ordering.

To reproduce, unpack the attached zip and run the following

mvn clean package
mvn dependency:copy-dependencies
java -cp "target/dependency/*:target/test-classes/" org.testng.TestNG test-suite-package.xml

When I do this, I see the methods in the class called Concrete (or inherited into it) called before those in the Precondition class (which I've arranged to make the test fail), even though Concrete has a dependsOnGroups annotation which should force Precondition run first.

FYI, this is an attempt to simplify down a situation I saw in a much larger test set. It may be that further simplification is possible (e.g. the DataProvider used in Precondition may be unnecessary, but reflects the original structure I saw).

On the other hand, perhaps this scenario is not expected to work. I couldn't find any detailed documentation on how class level annotations are expected to apply when @Test annotations on methods are inherited from a super-class, but if such documentation does exist and explains the behavior

I'm seeing, I'd appreciate a pointer.

testng-order-test.zip

juherr commented 8 years ago

Is it the same behavior that #952?

mattsheppard commented 8 years ago

No, I don't think it's the same issue from my reading - That one seems to be about the order of methods within the class correct, where as in this case the dependsOnGroups seems not to apply.

At a guess, I think it's not applying because the related @Test methods are on the superclass, not the same class which has the dependsOnGroups on the class, however that seems unexpected/undesirable unless I'm missing something.