Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

What happens between @AfterTest & ITestListener.onFinish()

51 views
Skip to first unread message

Andrew M

unread,
Feb 12, 2025, 2:04:33 PMFeb 12
to testng-users
Hello.  I am having an issue with TestNg failing to generate a "testng-results.xml" file.  This happens only occasionally so it's hard to reproduce and get good info.
I cannot find anything wrong and cannot find any logs with anything useful.  The same suite of tests usually passes so there should not be anything mis-configured.

It passes up to and including: @AfterMethod, @AfterClass and @AfterTest but fails before it hits ITestListener.onFinish() (we have custom code in there to do stuff).  The test run is triggered in Java - not with a testng.xml file.

What happens between @AfterTest and ITestListener.onFinish() ?  Any ideas might be helpful.  Thanks.

As a side note, it does produce a "Command line suite\Command line test.html" file.  But nothing else in "test-output".

Krishnan Mahadevan

unread,
Feb 12, 2025, 10:43:13 PMFeb 12
to testng...@googlegroups.com
Can you please share the following:

1. What version of TestNG are you working with?
2. How are you running your tests
3. Can you please share what your listener looks like ?



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/testng-users/c1aaf1a9-283e-45fa-b63f-b7b0b0bf3ce8n%40googlegroups.com.

Andrew M

unread,
Feb 13, 2025, 1:37:32 PMFeb 13
to testng-users
We are using testng 6.14.3
Tests are run from Java something like:

TestNG testng = new TestNG();
TestListenerAdapter tla = new TestListenerAdapter();
TestListener cla = new TestListener();
ClassListener cl = new ClassListener();
PriorityInterceptor pi = new PriorityInterceptor();
AnnotationTransformer at = new AnnotationTransformer();

testng.addListener(tla);
testng.addListener(cla);
testng.addListener(pi);
testng.addListener(at);
testng.addListener(cl);

// Add classes to run ....

try {
testng.run();
} catch (Exception e) {
   Utilities.log(Const.Log.ERROR, "executeTestScript(): Unexpected error encountered; exception: " + e);
}

Our TestListener.onFinish() method has a log line at the beginning to indicate the start of the method but we never hit that line.
This passes 90% of the time and only fails 10% of the time.  It started to fail around the time we switched to MySQL v8.  I fully acknowledge that this is almost certainly NOT an issue with TestNg.  The problem has got to be on our side somewhere.  The problem is: I'm not sure how to figure out exactly what is going wrong.

From debugging, I can see that "Command line suite\Command line test.html" is created sometime between @AfterTest and TestListener.onFinish(), which is what I see when things fail too.
When it passes, I get a "Command line suite\Command line test.xml" & "Command line suite\testng-failed.xml" too.  But when it fails, I do not.  So, my current best guess is that something is failing when trying to create "Command line suite\Command line test.xml" (and/or "Command line suite\testng-failed.xml").

The rest of the content of "test-output" like "testng-results.xml" is not created until after testng.run() is done.

I will keep trying....
Reply all
Reply to author
Forward
0 new messages