Skip to content

Listener's onAfterClass is called before @AfterClass configuration methods are executed. #2796

@pshevche

Description

@pshevche

TestNG Version

7.6.1 and older

Expected behavior

I would expect that listener's onAfterClass method is executed after onConfiguration* methods for all methods annotated with @AfterClass are called. Similarly to how onBeforeClass is called before the first method annotated with @BeforeClass is called.

Or at least that the ordering is consistent for both types of configuration methods.

Actual behavior

  • onBeforeClass is called before configuration methods annotated w/ @BeforeClass are executed.
  • onAfterClass is called before configuration methods annotated w/ @AfterClass are executed.

Is the issue reproducible on runner?

Issue is reproducible both on Gradle and Maven runners, did not check anything else. Here is a small Gradle project with listener and test case implementations that illustrates the problem: https://github.com/pshevche/testng-after-class-order-reproducer

Test case sample

Actual output:

onBeforeClass: dev.pshevche.AfterClassTest
onConfigurationSuccess: setupClass
onTestStart: test1
onTestSuccess: test1
onAfterClass: dev.pshevche.AfterClassTest
onConfigurationSuccess: cleanupClass

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions