TestNG unable to detect IInvokedMethodListener

View: New views
14 Messages — Rating Filter:   Alert me  

TestNG unable to detect IInvokedMethodListener

by S M Humayun :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I created a class that implements both IInvokedMethodListener and
ITestListener:

public class TestMethodListener implements IInvokedMethodListener,
ITestListener

And then configured it as follows:

<suite...>
    <listeners>
        <listener class-
name="com.iblgrp.common.core.test.helper.TestMethodListener"/>
    </listeners>
    <test...>
</suite>

When I ran tests only ITestListener callback methods were called and
not those of IInvokedMethodListener. Is it supposed to work that way
or am I missing some thing?

regards,

Humayun.

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


Re: TestNG unable to detect IInvokedMethodListener

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Humayun,

I just tested with a class that implements both interfaces and I see all the callbacks being invoked correctly.

Are you using Eclipse?  Can you try with the command line only?

--
Cédric



On Wed, Nov 4, 2009 at 3:52 AM, S M Humayun <smhumayun@...> wrote:

Hi,

I created a class that implements both IInvokedMethodListener and
ITestListener:

public class TestMethodListener implements IInvokedMethodListener,
ITestListener

And then configured it as follows:

<suite...>
   <listeners>
       <listener class-
name="com.iblgrp.common.core.test.helper.TestMethodListener"/>
   </listeners>
   <test...>
</suite>

When I ran tests only ITestListener callback methods were called and
not those of IInvokedMethodListener. Is it supposed to work that way
or am I missing some thing?

regards,

Humayun.






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


IAnnotationTransformer2 with @Factory

by pranav-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


List,

I was trying to implement IAnnotationTransformer2 based listener for my
TestNG Factory.  Right now though my factory runs multiple testcases,
the listener only gets called once. it calls both of the following
method once

public void transform(ITestAnnotation annotation, Class
testClass,Constructor testConstructor, Method testMethod)
public void transform(IFactoryAnnotation arg0, Method arg1)

but I was expecting it to call them once for each testcase.

just to give you guys context, I am trying to transform group
annotations for each of my @factory testcase.

is there some other way to achieve it?

Best,
Pranav

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


Re: IAnnotationTransformer2 with @Factory

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can you post the source of your factory and your XML file?

Thanks.

--
Cedric


On Wed, Nov 4, 2009 at 3:51 PM, Pranav <pranav.verma@...> wrote:

List,

I was trying to implement IAnnotationTransformer2 based listener for my
TestNG Factory.  Right now though my factory runs multiple testcases,
the listener only gets called once. it calls both of the following
method once

public void transform(ITestAnnotation annotation, Class
testClass,Constructor testConstructor, Method testMethod)
public void transform(IFactoryAnnotation arg0, Method arg1)

but I was expecting it to call them once for each testcase.

just to give you guys context, I am trying to transform group
annotations for each of my @factory testcase.

is there some other way to achieve it?

Best,
Pranav





--
Cédric



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


Re: IAnnotationTransformer2 with @Factory

by pranav-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i have attached the zipped src folder with this mail. please have a
look. if you run it , you will see this output

java -classpath .:../Lib/testng-5.9-jdk15.jar org.testng.TestNG testng.xml
[Parser] Running:
Itest/src/testng.xml

called : transform(IFactoryAnnotation arg0, Method arg1)
called : transform(ITestAnnotation annotation, Class
testClass,Constructor testConstructor, Method testMethod)
ITest:getTestName Called
ITest:getTestName Called
ITest:getTestName Called
ITest:getTestName Called
ITest:getTestName Called
PASSED: someTest (Test1)
PASSED: someTest (Test4)
PASSED: someTest (Test0)
PASSED: someTest (Test3)
PASSED: someTest (Test2)

===============================================
ItestDemo
Tests run: 5, Failures: 0, Skips: 0
===============================================


===============================================
testSuite
Total tests run: 5, Failures: 0, Skips: 0
===============================================




Cédric Beust ♔ wrote:

> Can you post the source of your factory and your XML file?
>
> Thanks.
>
> --
> Cedric
>
>
> On Wed, Nov 4, 2009 at 3:51 PM, Pranav <pranav.verma@...
> <mailto:pranav.verma@...>> wrote:
>
>
>     List,
>
>     I was trying to implement IAnnotationTransformer2 based listener
>     for my
>     TestNG Factory. Right now though my factory runs multiple testcases,
>     the listener only gets called once. it calls both of the following
>     method once
>
>     public void transform(ITestAnnotation annotation, Class
>     testClass,Constructor testConstructor, Method testMethod)
>     public void transform(IFactoryAnnotation arg0, Method arg1)
>
>     but I was expecting it to call them once for each testcase.
>
>     just to give you guys context, I am trying to transform group
>     annotations for each of my @factory testcase.
>
>     is there some other way to achieve it?
>
>     Best,
>     Pranav
>
>
>
>
>
> --
> **/*Cédric*
> /
>
>
> >

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



src.zip (18K) Download Attachment

Re: TestNG unable to detect IInvokedMethodListener

by S M Humayun :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am using TestNG 5.9 with Maven Surefire Plugin configured as
follows:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/testng.xml</
suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>

Do note that I didn't mention any version in the plugin config above.

I've already posted the testng.xml in my previous email quoted below
and I am using JetBrain's Intellij IDEA.

- Humayun.

On Nov 4, 11:08 pm, Cédric Beust ♔ <cbe...@...> wrote:

> Hi Humayun,
>
> I just tested with a class that implements both interfaces and I see all the
> callbacks being invoked correctly.
>
> Are you using Eclipse?  Can you try with the command line only?
>
> --
> ***Cédric
> *
>
> On Wed, Nov 4, 2009 at 3:52 AM, S M Humayun <smhuma...@...> wrote:
>
>
>
>
>
> > Hi,
>
> > I created a class that implements both IInvokedMethodListener and
> > ITestListener:
>
> > public class TestMethodListener implements IInvokedMethodListener,
> > ITestListener
>
> > And then configured it as follows:
>
> > <suite...>
> >    <listeners>
> >        <listener class-
> > name="com.iblgrp.common.core.test.helper.TestMethodListener"/>
> >    </listeners>
> >    <test...>
> > </suite>
>
> > When I ran tests only ITestListener callback methods were called and
> > not those of IInvokedMethodListener. Is it supposed to work that way
> > or am I missing some thing?
>
> > regards,
>
> > Humayun.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: TestNG unable to detect IInvokedMethodListener

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can you try without Surefire?  This Maven plug-in seems to cause a lot of problems...

--
Cedric


On Wed, Nov 4, 2009 at 8:27 PM, S M Humayun <smhumayun@...> wrote:

I am using TestNG 5.9 with Maven Surefire Plugin configured as
follows:

           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <configuration>
                   <suiteXmlFiles>
                       <suiteXmlFile>src/test/resources/testng.xml</
suiteXmlFile>
                   </suiteXmlFiles>
               </configuration>
           </plugin>

Do note that I didn't mention any version in the plugin config above.

I've already posted the testng.xml in my previous email quoted below
and I am using JetBrain's Intellij IDEA.

- Humayun.

On Nov 4, 11:08 pm, Cédric Beust ♔ <cbe...@...> wrote:
> Hi Humayun,
>
> I just tested with a class that implements both interfaces and I see all the
> callbacks being invoked correctly.
>
> Are you using Eclipse?  Can you try with the command line only?
>
> --
> ***Cédric
> *
>
> On Wed, Nov 4, 2009 at 3:52 AM, S M Humayun <smhuma...@...> wrote:
>
>
>
>
>
> > Hi,
>
> > I created a class that implements both IInvokedMethodListener and
> > ITestListener:
>
> > public class TestMethodListener implements IInvokedMethodListener,
> > ITestListener
>
> > And then configured it as follows:
>
> > <suite...>
> >    <listeners>
> >        <listener class-
> > name="com.iblgrp.common.core.test.helper.TestMethodListener"/>
> >    </listeners>
> >    <test...>
> > </suite>
>
> > When I ran tests only ITestListener callback methods were called and
> > not those of IInvokedMethodListener. Is it supposed to work that way
> > or am I missing some thing?
>
> > regards,
>
> > Humayun.




--
Cédric



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


Re: IAnnotationTransformer2 with @Factory

by pranav-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


on second thoughts, this is never suppose to happen, coz if I understand
right, testng scans/loads annotations at the start, hence transforming
should happen at that time only....and I wanted to change them during
the test run. It probably against the design to up[date the annotations
during test execution... can somebody please confirm that ?


right now we have implemented groups feature, by adding some custom
filtering logic in my Factory class...... it works just fine for us .

Best,
Pranav


Pranav wrote:

> i have attached the zipped src folder with this mail. please have a
> look. if you run it , you will see this output
>
> java -classpath .:../Lib/testng-5.9-jdk15.jar org.testng.TestNG
> testng.xml
> [Parser] Running:
> Itest/src/testng.xml
>
> called : transform(IFactoryAnnotation arg0, Method arg1)
> called : transform(ITestAnnotation annotation, Class
> testClass,Constructor testConstructor, Method testMethod)
> ITest:getTestName Called
> ITest:getTestName Called
> ITest:getTestName Called
> ITest:getTestName Called
> ITest:getTestName Called
> PASSED: someTest (Test1)
> PASSED: someTest (Test4)
> PASSED: someTest (Test0)
> PASSED: someTest (Test3)
> PASSED: someTest (Test2)
>
> ===============================================
> ItestDemo
> Tests run: 5, Failures: 0, Skips: 0
> ===============================================
>
>
> ===============================================
> testSuite
> Total tests run: 5, Failures: 0, Skips: 0
> ===============================================
>
>
>
>
> Cédric Beust ♔ wrote:
>> Can you post the source of your factory and your XML file?
>>
>> Thanks.
>>
>> --
>> Cedric
>>
>>
>> On Wed, Nov 4, 2009 at 3:51 PM, Pranav <pranav.verma@...
>> <mailto:pranav.verma@...>> wrote:
>>
>>
>>     List,
>>
>>     I was trying to implement IAnnotationTransformer2 based listener
>>     for my
>>     TestNG Factory. Right now though my factory runs multiple testcases,
>>     the listener only gets called once. it calls both of the following
>>     method once
>>
>>     public void transform(ITestAnnotation annotation, Class
>>     testClass,Constructor testConstructor, Method testMethod)
>>     public void transform(IFactoryAnnotation arg0, Method arg1)
>>
>>     but I was expecting it to call them once for each testcase.
>>
>>     just to give you guys context, I am trying to transform group
>>     annotations for each of my @factory testcase.
>>
>>     is there some other way to achieve it?
>>
>>     Best,
>>     Pranav
>>
>>
>>
>>
>>
>> --
>> **/*Cédric*
>> /
>>
>>
>> >>
>


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


Re: IAnnotationTransformer2 with @Factory

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Pranav,

On Wed, Nov 4, 2009 at 11:51 PM, Pranav <pranav.verma@...> wrote:

on second thoughts, this is never suppose to happen, coz if I understand
right, testng scans/loads annotations at the start, hence transforming
should happen at that time only....and I wanted to change them during
the test run. It probably against the design to up[date the annotations
during test execution... can somebody please confirm that ?


Correct, the annotation transformers modify the annotations before the TestNG engine sees them.

--
Cédric



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


Re: IAnnotationTransformer2 with @Factory

by pranav-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks for the confirmation Cédric :)

Best,
Pranav

Cédric Beust ♔ wrote:

> Hi Pranav,
>
> On Wed, Nov 4, 2009 at 11:51 PM, Pranav <pranav.verma@...
> <mailto:pranav.verma@...>> wrote:
>
>
>     on second thoughts, this is never suppose to happen, coz if I
>     understand
>     right, testng scans/loads annotations at the start, hence transforming
>     should happen at that time only....and I wanted to change them during
>     the test run. It probably against the design to up[date the
>     annotations
>     during test execution... can somebody please confirm that ?
>
>
> Correct, the annotation transformers modify the annotations before the
> TestNG engine sees them.
>
> --
> **/*Cédric*
> /
>


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


Re: TestNG unable to detect IInvokedMethodListener

by S M Humayun :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Are there any other plugins available to integrate Maven with TestNG?

Though, I've managed to do the same using ITestListener, which is
working fine. Actually, I just wanted to log following:

--- <TestMethodName> : START ---

before test and following:

--- <TestMethodName> : END ---

after test.

You might ask why I didn't use @Before and @After annotations, thats
because I didn't find a way to get the actual test method name and
then I stumble upon IInvokedMethodListener and ITestListener and the
later one did the trick for me. Is there a better way of doing this?
provided that I have to use TestNG with Maven.

--------------------------------------------
S M Humayun
Software Architect, IBL Group
--------------------------------------------
Email : smhumayun@...
MSN   : smhumayun2001@...
Skype : smhumayun
Cell  : 92.321.8707783
Blog  : http://smhumayun.blogspot.com
Link  : http://www.linkedin.com/in/smhumayun
Facebook : http://www.facebook.com/smhumayun
Twitter : http://twitter.com/smhumayun
--------------------------------------------





2009/11/5 Cédric Beust ♔ <cbeust@...>:

> Can you try without Surefire?  This Maven plug-in seems to cause a lot of
> problems...
>
> --
> Cedric
>
>
> On Wed, Nov 4, 2009 at 8:27 PM, S M Humayun <smhumayun@...> wrote:
>>
>> I am using TestNG 5.9 with Maven Surefire Plugin configured as
>> follows:
>>
>>            <plugin>
>>                <groupId>org.apache.maven.plugins</groupId>
>>                <artifactId>maven-surefire-plugin</artifactId>
>>                <configuration>
>>                    <suiteXmlFiles>
>>                        <suiteXmlFile>src/test/resources/testng.xml</
>> suiteXmlFile>
>>                    </suiteXmlFiles>
>>                </configuration>
>>            </plugin>
>>
>> Do note that I didn't mention any version in the plugin config above.
>>
>> I've already posted the testng.xml in my previous email quoted below
>> and I am using JetBrain's Intellij IDEA.
>>
>> - Humayun.
>>
>> On Nov 4, 11:08 pm, Cédric Beust ♔ <cbe...@...> wrote:
>> > Hi Humayun,
>> >
>> > I just tested with a class that implements both interfaces and I see all
>> > the
>> > callbacks being invoked correctly.
>> >
>> > Are you using Eclipse?  Can you try with the command line only?
>> >
>> > --
>> > ***Cédric
>> > *
>> >
>> > On Wed, Nov 4, 2009 at 3:52 AM, S M Humayun <smhuma...@...> wrote:
>> >
>> >
>> >
>> >
>> >
>> > > Hi,
>> >
>> > > I created a class that implements both IInvokedMethodListener and
>> > > ITestListener:
>> >
>> > > public class TestMethodListener implements IInvokedMethodListener,
>> > > ITestListener
>> >
>> > > And then configured it as follows:
>> >
>> > > <suite...>
>> > >    <listeners>
>> > >        <listener class-
>> > > name="com.iblgrp.common.core.test.helper.TestMethodListener"/>
>> > >    </listeners>
>> > >    <test...>
>> > > </suite>
>> >
>> > > When I ran tests only ITestListener callback methods were called and
>> > > not those of IInvokedMethodListener. Is it supposed to work that way
>> > > or am I missing some thing?
>> >
>> > > regards,
>> >
>> > > Humayun.
>>
>
>
>
> --
> Cédric
>
>
>
> >
>

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


Re: TestNG unable to detect IInvokedMethodListener

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Thu, Nov 5, 2009 at 1:21 AM, S M Humayun <smhumayun@...> wrote:

Are there any other plugins available to integrate Maven with TestNG?

Though, I've managed to do the same using ITestListener, which is
working fine. Actually, I just wanted to log following:

--- <TestMethodName> : START ---

before test and following:

--- <TestMethodName> : END ---

after test.

You might ask why I didn't use @Before and @After annotations, thats
because I didn't find a way to get the actual test method name

Just declare a parameter of type Method in your @BeforeMethod and TestNG will inject the test method for you.

--
Cédric



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


Re: TestNG unable to detect IInvokedMethodListener

by S M Humayun :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanx for the pointer.

I am using 5.9, which does not supports ITestResult parameter
injection in @AfterMethod and I tried using Method parameter injection
and it works ! However, nowhere in the doc
(http://testng.org/doc/documentation-main.html#dependency-injection)
is mentioned that @AfterMethod also supports Method parameter
injection.

--------------------------------------------
S M Humayun
Software Architect, IBL Group
--------------------------------------------
Email : smhumayun@...
MSN   : smhumayun2001@...
Skype : smhumayun
Cell  : 92.321.8707783
Blog  : http://smhumayun.blogspot.com
Link  : http://www.linkedin.com/in/smhumayun
Facebook : http://www.facebook.com/smhumayun
Twitter : http://twitter.com/smhumayun
--------------------------------------------





2009/11/5 Cédric Beust ♔ <cbeust@...>:

>
>
> On Thu, Nov 5, 2009 at 1:21 AM, S M Humayun <smhumayun@...> wrote:
>>
>> Are there any other plugins available to integrate Maven with TestNG?
>>
>> Though, I've managed to do the same using ITestListener, which is
>> working fine. Actually, I just wanted to log following:
>>
>> --- <TestMethodName> : START ---
>>
>> before test and following:
>>
>> --- <TestMethodName> : END ---
>>
>> after test.
>>
>> You might ask why I didn't use @Before and @After annotations, thats
>> because I didn't find a way to get the actual test method name
>
> Just declare a parameter of type Method in your @BeforeMethod and TestNG
> will inject the test method for you.
>
> --
> Cédric
>
>
>
> >
>

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


Re: TestNG unable to detect IInvokedMethodListener

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Thu, Nov 5, 2009 at 9:19 PM, S M Humayun <smhumayun@...> wrote:

Thanx for the pointer.

I am using 5.9, which does not supports ITestResult parameter
injection in @AfterMethod and I tried using Method parameter injection
and it works ! However, nowhere in the doc
(http://testng.org/doc/documentation-main.html#dependency-injection)
is mentioned that @AfterMethod also supports Method parameter
injection.

Good catch, I must have missed it.  I fixed it on the web site.

Thanks!

--
Cédric



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