Run java -cp testng-7.12.0.jar:jcommander-1.83.jar:slf4j-api-2.0.16.jar:. org.testng.TestNG -testclass YourTest and TestNG calls your listeners in a fixed order: suite-level first, then per-method onTestStart → beforeInvocation → your test body → afterInvocation → the pass/fail/skip callback, repeated per method, then suite-level again on the way out. That order — and what happens to a listener when a test is skipped rather than failed — is the useful, checkable half the old page never established. It listed eight listener interfaces and described each in a sentence; below is what one of them actually does, measured.
Setup: no Maven, no Gradle, just the jar
TestNG’s own README states it requires Java 11 or higher to run; it doesn’t state an upper bound. Maven Central’s maven-metadata.xml for org.testng:testng lists 7.12.0 as both <latest> and <release>. It compiled and ran cleanly against JDK 26.0.2 with zero errors or deprecation warnings — that’s the JDK-compatibility finding: nothing in the brief for this page was wrong, TestNG runs on 26 without qualification.
One pitfall building the classpath by hand: TestNG 7.12.0’s POM depends on org.jcommander:jcommander:1.83, not com.beust:jcommander. The com.beust groupId tops out at 1.82 on Maven Central — jcommander migrated groupIds. Any tutorial or Stack Overflow answer still pointing at com.beust:jcommander:1.83 will 404. You also need slf4j-api on the classpath (2.0.16, per the same POM) or TestNG throws NoClassDefFoundError: org/slf4j/LoggerFactory before it runs a single test; a “no SLF4J providers” warning after that is normal and harmless.
What the callbacks actually do, in order
A three-method class — one pass, one deliberate failure, and one method with dependsOnMethods pointing at the failed one — with a listener implementing ITestListener, ISuiteListener, and IInvokedMethodListener together, run with -testclass. Unedited output:
[ISuiteListener] onStart: Command line suite
[ITestListener] onStart (context): Command line test
[ITestListener] onTestStart: testOnePasses
[IInvokedMethodListener] beforeInvocation: testOnePasses
>> running testOnePasses
[IInvokedMethodListener] afterInvocation: testOnePasses
[ITestListener] onTestSuccess: testOnePasses
[ITestListener] onTestStart: testTwoFails
[IInvokedMethodListener] beforeInvocation: testTwoFails
>> running testTwoFails
[IInvokedMethodListener] afterInvocation: testTwoFails
[ITestListener] onTestFailure: testTwoFails
[ITestListener] onTestStart: testThreeSkipped
[IInvokedMethodListener] beforeInvocation: testThreeSkipped
[IInvokedMethodListener] afterInvocation: testThreeSkipped
[ITestListener] onTestSkipped: testThreeSkipped
[ITestListener] onFinish (context): Command line test
[ISuiteListener] onFinish: Command line suite
===============================================
Command line suite
Total tests run: 3, Passes: 1, Failures: 1, Skips: 1
===============================================
The skip case is the finding worth having: for testThreeSkipped, IInvokedMethodListener.beforeInvocation and afterInvocation both fire — but the line the test method itself prints (>> running testThreeSkipped) never appears, because a failed dependency skips the actual method body while TestNG still wraps the invocation attempt in those two callbacks. ITestListener.onTestSkipped fires where onTestSuccess/onTestFailure would. If you’re using IInvokedMethodListener to time test execution, it will happily time a method that never ran.
ISuiteListener brackets everything; ITestListener‘s context callbacks bracket each <test> block; the four method-level callbacks repeat per test method. That nesting is the actual answer to “what’s the difference between ITestListener and IInvokedMethodListener“: one reports outcomes, the other reports invocation attempts, and they are not the same set of events for a skipped method.
The exit code is a bitmask
Run the suite above through echo $? and you get 3, not a pass/fail boolean. Isolating each case: a suite with only a pass exits 0; only a failure, 1; a SkipException with nothing else failing, 2; fail and skip together, 3. That’s 1 for “contains a failure” OR’d with 2 for “contains a skip” — useful if a CI step greps for a specific bit instead of just “non-zero.”
This page is about listener callback order specifically — not testng.xml suite
files, not parameterization, and not how TestNG compares to JUnit. Everything above was run on
JDK 26; if you are choosing which JDK to run your suite on, see
which Java distribution to use.
The verification script downloads the same jars from Maven Central if they aren’t cached, compiles the same three-method suite, runs it, and checks the callback order and exit code above against what actually happens on the machine that runs it.