Not able to run Custom TestListener from command line maven project

1,043 views
Skip to first unread message

Ravi Saurabh

unread,
Jun 19, 2012, 1:44:48 PM6/19/12
to testng...@googlegroups.com
Hi,
I have create a maven project. In this project I have also created a customTestListener which extends TestListenerAdapter.
I want to run testNG based test cases using testng.xml file from command line, but unable to run customTestListener .

I tried following things:
1> Mentioned the listener in testng.xml:
<listeners>
        <listener
            class-name="com.mycompany.product.api.automation.test.common.cutomTestListener" />
    </listeners>

this configuration works well from eclipse but not from commandline

 2> In second approach, I mentioned the custom TestListener in surefire-plugin in pom.xml, but again my testListene failed to run through commandline, although my testcases are working fine.
 
I have also attached my pom.xml file for your reference.

Please help me to solve this..

-- Thanks
~ Ravi

pom.xml

Ravi Saurabh

unread,
Jun 20, 2012, 11:51:21 AM6/20/12
to testng...@googlegroups.com
Can someone help me out. It's rather critical for me.
--
~ Ravi Saurabh

Krishnan Mahadevan

unread,
Jun 20, 2012, 11:55:09 AM6/20/12
to testng...@googlegroups.com
There is a typo error in your pom file

- <property>
  <name>listener</name>
  <value>com.mycompany.product.api.automation.test.common.cutomTestListner</value>
  </property>

Can you please change the value to the correct fully qualified name of your Listener and see if that helps ?

Change : com.mycompany.product.api.automation.test.common.cutomTestListner (Notice that TestListener is incorrectly spelt)
To : com.mycompany.product.api.automation.test.common.cutomTestListener

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



On Tue, Jun 19, 2012 at 11:14 PM, Ravi Saurabh <saura...@gmail.com> wrote:

~ Ravi

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Ravi Saurabh

unread,
Jun 20, 2012, 10:53:00 PM6/20/12
to testng...@googlegroups.com
Hi Krishna.
Thanks for your reply. This is just an example. My customtestListner class extends TestListenerAdapter. Then how does it matter with the name? I could even give the name ABC there.

For an example:
Class ABC extends TestListenerAdapter{
     // some code
}

Now in POM.xml file:
<property>
  <name>listener</name>
  <value>com.mycompany.product.api.automation.test.common.ABC</value>
  </property>

Thanks,
Ravi
--
~ Ravi Saurabh

Krishnan Mahadevan

unread,
Jun 20, 2012, 11:05:44 PM6/20/12
to testng...@googlegroups.com
Is the fully qualified name of your custom listener spelled out clearly in your pom file? That is what I was trying to ascertain!
My Scribblings @ http://wakened-cognition.blogspot.com/

Tomek Kaczanowski

unread,
Jun 21, 2012, 2:55:16 AM6/21/12
to testng...@googlegroups.com
which surefire version you use?

--
Regards / Pozdrawiam
Tomek Kaczanowski
http://practicalunittesting.com

2012/6/21 Krishnan Mahadevan <krishnan.ma...@gmail.com>:

Ravi Saurabh

unread,
Jun 21, 2012, 1:18:18 PM6/21/12
to testng...@googlegroups.com
 Surefire version is 2.12. Although when I mentioned the same listener in my testng.xml file it's  started working fine..

SUBRAMANYESWARA RAO BHAVIRISETTY

unread,
Jun 21, 2012, 1:57:36 PM6/21/12
to testng...@googlegroups.com
Hi Ravi,

I am able to use the custom listeners.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<suiteXmlFiles>

<suiteXmlFile>src/test/resources/testng-${testtype}.xml</suiteXmlFile>
</suiteXmlFiles>
<configuration>
<skipTests>${skipTests}</skipTests>
</configuration>

<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>

<value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
</configuration>
</plugin>


If we see the above entries, I am using
org.uncommons.reportng.HTMLReporter and
org.uncommons.reportng.JUnitXMLReporter and it seems to work fine.

I guess you need to set usedefaultlisteners to false.

Please check the section(Using custom listeners and reporters) at this
link http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html.

Let me know if you have any issues.

~Subramanyam
> *~ Ravi Saurabh*
>
> --
> You received this message because you are subscribed to the Google Groups
> "testng-users" group.
> To post to this group, send email to testng...@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-users?hl=en.
>
>


--
Subramanyam
Reply all
Reply to author
Forward
0 new messages