testng icon indicating copy to clipboard operation
testng copied to clipboard

dependsOnGroups on @AfterMethod seems to behave incorrectly

Open seagri opened this issue 3 years ago • 1 comments

TestNG Version

7.5

Scenario

After method in Base class is executed before the one in the Child class

When using version 6.14.3 then the result is as the "expected behavior". On 7.4.0 it is also as the excepted result but when adding groups = { "afterMethod" } to @AfterMethod as @AfterMethod(alwaysRun = true, groups = { "afterMethod" }, dependsOnGroups = { "beforeMethod" }) it produces the wrong result again.

This probably can bee seen on other annotations that the user uses.

Expected behavior

@BeforeMethod BaseClass @BeforeMethod ChildClass @Test testCase @AfterMethod ChildClass @AfterMethod BaseClass

Actual behavior

@BeforeMethod BaseClass @BeforeMethod ChildClass @Test testCase @AfterMethod BaseClass <--- Swapped @AfterMethod ChildClass <--- Swapped

Is the issue reproducible on runner?

  • [ ] Shell
  • [ ] Maven
  • [ ] Gradle
  • [ ] Ant
  • [x] Eclipse
  • [x] IntelliJ
  • [ ] NetBeans

Test case sample

public class BaseClass {
    @BeforeMethod(groups = { "beforeMethod" })
    public void beforeMethod() {
        System.out.println("@BeforeMethod BaseClass");
    }

    @AfterMethod(alwaysRun = true, dependsOnGroups = { "beforeMethod" })
    public void afterMethod() {
        System.out.println("@AfterMethod BaseClass");
    }
}
public class ChildClass extends BaseClass {
    @BeforeMethod
    public void beforeChildMethod() {
        System.out.println("@BeforeMethod ChildClass");
    }

    @AfterMethod
    public void afterChildMethod() {
        System.out.println("@AfterMethod ChildClass");
    }

    @Test
    public void testCase() {
        System.out.println("@Test testCase");
    }
}

seagri avatar Jan 12 '22 13:01 seagri