why isn't Gradle running my TestNG testlistener?

1,031 views
Skip to first unread message

Todd Bradley

unread,
Sep 11, 2017, 11:35:50 AM9/11/17
to testng-users
Hi, I have a test listener, creatively named oracle.cloudstorage.qa.testListener.testListener. When I run TestNG tests from the command line using the -listener command line argument, my listener is instantiated and invoked as part of the TestNG startup, as expected. But when I run the tests from Gradle, using the TestNG plugin, my listener isn't invoked.

My build.gradle file has this as the task:

task productionTestMild(type: Test) {
useTestNG() {
includeGroups "production-mild"
excludeGroups "bug"
include 'com/cloudstorage/qa/**'
useDefaultListeners = true

options {
options.parallel = "classes"
options.threadCount = 3
// This doesn't seem to actually work
options.listeners << "com.cloudstorage.qa.testListener.testListener"
}
}
}

The options.parallel and options.threadCount seem to be honored, but not options.listeners. Can you see what I'm doing wrong? I'm using TestNG 6.11 and Gradle 2.13.

Thanks,
Todd.

Krishnan Mahadevan

unread,
Sep 11, 2017, 11:53:44 AM9/11/17
to testng...@googlegroups.com

I was able to have the listener invoked by adding it as below :

 

useTestNG() {
    suites
'src/test/resources/krmahadevan.xml'
   
systemProperties(System.getProperties())
    options {
        listeners.add(
"com.rationaleemotions.EchoListener")
    }
}

 

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 Scribbings @ http://rationaleemotions.wordpress.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 post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Todd Bradley

unread,
Sep 11, 2017, 1:07:10 PM9/11/17
to testng...@googlegroups.com
Thanks, Krishnan. It was completely user error. I was using the wrong listener. But I did switch to your style of configuring it, except that my "listeners.add" isn't inside of options {}. It's just inside useTestNG() {}. It still seems to work.

To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.


To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages