BeforeMethod parameter values

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

BeforeMethod parameter values

David R-6

How do i obtain the value of the actual parameter that is passed to
the method?
If i use beforeMethod is it there is the IContext and i do not see it?
Or is my only recourse to use a listener?

My goal is similar to what someone else posted -- that for any
parameter sent, i want to use that parameter in the BeforeMethod to do
some setup.
Currently, i need to do all my setup as part of the test.

TIA,
David

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

Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

David R-6

Is there anyone out there that can point me in the right direction for
what i need to do?
I want to use before and after methods for my code that require the
dataprovider data.

On Jun 5, 1:20 pm, David R <[hidden email]> wrote:

> How do i obtain the value of the actualparameterthat is passed to
> the method?
> If i usebeforeMethodis it there is the IContext and i do not see it?
> Or is my only recourse to use a listener?
>
> My goal is similar to what someone else posted -- that for anyparametersent, i want to use thatparameterin theBeforeMethodto do
> some setup.
> Currently, i need to do all my setup as part of the test.
>
> TIA,
> David

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

Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

Cédric Beust ♔
Hi David,

I just implemented this feature.  You can now declare an Object[] parameter in your @BeforeMethod method and it will be filled with the parameters that are about to be injected into the test method.

Please download:


and let me know if it fixes your problem.

--
Cedric


On Wed, Jun 11, 2008 at 3:43 AM, David R <[hidden email]> wrote:

Is there anyone out there that can point me in the right direction for
what i need to do?
I want to use before and after methods for my code that require the
dataprovider data.

On Jun 5, 1:20 pm, David R <[hidden email]> wrote:
> How do i obtain the value of the actualparameterthat is passed to
> the method?
> If i usebeforeMethodis it there is the IContext and i do not see it?
> Or is my only recourse to use a listener?
>
> My goal is similar to what someone else posted -- that for anyparametersent, i want to use thatparameterin theBeforeMethodto do
> some setup.
> Currently, i need to do all my setup as part of the test.
>
> TIA,
> David





--
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 [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

Mark Derricutt
Is this also available for @AfterMethod at all?

Actually, earlier I was updating some test code and thought it'd it be handy to have some way of doing:

@AfterDataProviderMethod
public void postProcess(Object[][] data) {
...

which would fire after all data from a data provider has been run through a test, optionally passing in the data that was processed.

To be useful you'd probably also need a ITestResult[] array so we could tell which iterations passed or failed.

Not sure of a decent way of presenting this thou off hand.  Would anyone else find this handy?


On Fri, Jun 13, 2008 at 7:03 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi David,

I just implemented this feature.  You can now declare an Object[] parameter in your @BeforeMethod method and it will be filled with the parameters that are about to be injected into the test method.

Please download:


and let me know if it fixes your problem.

--
Cedric



On Wed, Jun 11, 2008 at 3:43 AM, David R <[hidden email]> wrote:

Is there anyone out there that can point me in the right direction for
what i need to do?
I want to use before and after methods for my code that require the
dataprovider data.

On Jun 5, 1:20 pm, David R <[hidden email]> wrote:
> How do i obtain the value of the actualparameterthat is passed to
> the method?
> If i usebeforeMethodis it there is the IContext and i do not see it?
> Or is my only recourse to use a listener?
>
> My goal is similar to what someone else posted -- that for anyparametersent, i want to use thatparameterin theBeforeMethodto do
> some setup.
> Currently, i need to do all my setup as part of the test.
>
> TIA,
> David





--
Cédric





--
"It is easier to optimize correct code than to correct optimized code." -- Bill Harlan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

David R-6

First of all, Cedric, thanks for the implementation!

This would definitely be handy for the same reason as the
beforemethod, and as you indicate if i can know in the aftermethod if
the test was successful or not.
This cleans up my test functions to have less setup and cleanup.

David


On Jun 15, 12:13 pm, "Mark Derricutt" <[hidden email]> wrote:

> Is this also available for @AfterMethod at all?
>
> Actually, earlier I was updating some test code and thought it'd it be handy
> to have some way of doing:
>
> @AfterDataProviderMethod
> public void postProcess(Object[][] data) {
> ...
>
> which would fire after all data from a data provider has been run through a
> test, optionally passing in the data that was processed.
>
> To be useful you'd probably also need a ITestResult[] array so we could tell
> which iterations passed or failed.
>
> Not sure of a decent way of presenting this thou off hand.  Would anyone
> else find this handy?
>
> On Fri, Jun 13, 2008 at 7:03 AM, Cédric Beust ♔ <[hidden email]> wrote:
>
>
>
> > Hi David,
>
> > I just implemented this feature.  You can now declare an Object[] parameter
> > in your @BeforeMethod method and it will be filled with the parameters that
> > are about to be injected into the test method.
>
> > Please download:
>
> >http://testng.org/testng-5.8.1beta-jdk15.jar
>
> > and let me know if it fixes your problem.
>
> > --
> > Cedric
>
> > On Wed, Jun 11, 2008 at 3:43 AM, David R <[hidden email]> wrote:
>
> >> Is there anyone out there that can point me in the right direction for
> >> what i need to do?
> >> I want to use before and after methods for my code that require the
> >> dataprovider data.
>
> >> On Jun 5, 1:20 pm, David R <[hidden email]> wrote:
> >> > How do i obtain the value of the actualparameterthat is passed to
> >> > the method?
> >> > If i usebeforeMethodis it there is the IContext and i do not see it?
> >> > Or is my only recourse to use a listener?
>
> >> > My goal is similar to what someone else posted -- that for
> >> anyparametersent, i want to use thatparameterin theBeforeMethodto do
> >> > some setup.
> >> > Currently, i need to do all my setup as part of the test.
>
> >> > TIA,
> >> > David
>
> > --
> > Cédric
>
> --
> "It is easier to optimize correct code than to correct optimized code." --
> Bill Harlan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

Cédric Beust ♔
In reply to this post by Mark Derricutt


On Sun, Jun 15, 2008 at 2:13 AM, Mark Derricutt <[hidden email]> wrote:
Is this also available for @AfterMethod at all?

Yes, it works for @AfterMethod as well.

--
Cedric
 


Actually, earlier I was updating some test code and thought it'd it be handy to have some way of doing:

@AfterDataProviderMethod
public void postProcess(Object[][] data) {
...

which would fire after all data from a data provider has been run through a test, optionally passing in the data that was processed.

To be useful you'd probably also need a ITestResult[] array so we could tell which iterations passed or failed.

Not sure of a decent way of presenting this thou off hand.  Would anyone else find this handy?


On Fri, Jun 13, 2008 at 7:03 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi David,

I just implemented this feature.  You can now declare an Object[] parameter in your @BeforeMethod method and it will be filled with the parameters that are about to be injected into the test method.

Please download:


and let me know if it fixes your problem.

--
Cedric



On Wed, Jun 11, 2008 at 3:43 AM, David R <[hidden email]> wrote:

Is there anyone out there that can point me in the right direction for
what i need to do?
I want to use before and after methods for my code that require the
dataprovider data.

On Jun 5, 1:20 pm, David R <[hidden email]> wrote:
> How do i obtain the value of the actualparameterthat is passed to
> the method?
> If i usebeforeMethodis it there is the IContext and i do not see it?
> Or is my only recourse to use a listener?
>
> My goal is similar to what someone else posted -- that for anyparametersent, i want to use thatparameterin theBeforeMethodto do
> some setup.
> Currently, i need to do all my setup as part of the test.
>
> TIA,
> David





--
Cédric





--
"It is easier to optimize correct code than to correct optimized code." -- Bill Harlan





--
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 [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

Ben Mark
Hi Cedric,

When passing a POJO there's a runtime bug in the before method which can be seen while debugging.
When passing a POJO from the dataProvider to the test/beforemthod, the test gets that POJO but the beforeMethod gets something weird, it gets a 2d array containing  1 row with that pojo..
The before method accepts only Object [] array, and there is no way of reaching that injected pojo from the dataProvider.

Will be glad to post a mock project with a debug screenshot

A fix could help me and others alot

Thanks in advance Cedric
~Ben




On Monday, 16 June 2008 18:07:42 UTC+3, Cedric wrote:


On Sun, Jun 15, 2008 at 2:13 AM, Mark Derricutt <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zU-eisQRk_0J" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ma...@...> wrote:
Is this also available for @AfterMethod at all?

Yes, it works for @AfterMethod as well.

--
Cedric
 


Actually, earlier I was updating some test code and thought it'd it be handy to have some way of doing:

@AfterDataProviderMethod
public void postProcess(Object[][] data) {
...

which would fire after all data from a data provider has been run through a test, optionally passing in the data that was processed.

To be useful you'd probably also need a ITestResult[] array so we could tell which iterations passed or failed.

Not sure of a decent way of presenting this thou off hand.  Would anyone else find this handy?


On Fri, Jun 13, 2008 at 7:03 AM, Cédric Beust ♔ <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zU-eisQRk_0J" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">cbe...@...> wrote:
Hi David,

I just implemented this feature.  You can now declare an Object[] parameter in your @BeforeMethod method and it will be filled with the parameters that are about to be injected into the test method.

Please download:

<a href="http://testng.org/testng-5.8.1beta-jdk15.jar" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-5.8.1beta-jdk15.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHkPDw6z7sGhegymKx5VO-xPMRedA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-5.8.1beta-jdk15.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHkPDw6z7sGhegymKx5VO-xPMRedA&#39;;return true;">http://testng.org/testng-5.8.1beta-jdk15.jar

and let me know if it fixes your problem.

--
Cedric



On Wed, Jun 11, 2008 at 3:43 AM, David R <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zU-eisQRk_0J" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">drose...@...> wrote:

Is there anyone out there that can point me in the right direction for
what i need to do?
I want to use before and after methods for my code that require the
dataprovider data.

On Jun 5, 1:20 pm, David R <[hidden email]> wrote:
> How do i obtain the value of the actualparameterthat is passed to
> the method?
> If i usebeforeMethodis it there is the IContext and i do not see it?
> Or is my only recourse to use a listener?
>
> My goal is similar to what someone else posted -- that for anyparametersent, i want to use thatparameterin theBeforeMethodto do
> some setup.
> Currently, i need to do all my setup as part of the test.
>
> TIA,
> David





--
Cédric





--
"It is easier to optimize correct code than to correct optimized code." -- Bill Harlan





--
Cédric

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

Krishnan Mahadevan
Ben,
I guess this now stands resolved based on your response in this thread ?

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/

On Mon, Feb 6, 2017 at 1:58 PM, Ben Mark <[hidden email]> wrote:
Hi Cedric,

When passing a POJO there's a runtime bug in the before method which can be seen while debugging.
When passing a POJO from the dataProvider to the test/beforemthod, the test gets that POJO but the beforeMethod gets something weird, it gets a 2d array containing  1 row with that pojo..
The before method accepts only Object [] array, and there is no way of reaching that injected pojo from the dataProvider.

Will be glad to post a mock project with a debug screenshot

A fix could help me and others alot

Thanks in advance Cedric
~Ben




On Monday, 16 June 2008 18:07:42 UTC+3, Cedric wrote:


On Sun, Jun 15, 2008 at 2:13 AM, Mark Derricutt <[hidden email]> wrote:
Is this also available for @AfterMethod at all?

Yes, it works for @AfterMethod as well.

--
Cedric
 


Actually, earlier I was updating some test code and thought it'd it be handy to have some way of doing:

@AfterDataProviderMethod
public void postProcess(Object[][] data) {
...

which would fire after all data from a data provider has been run through a test, optionally passing in the data that was processed.

To be useful you'd probably also need a ITestResult[] array so we could tell which iterations passed or failed.

Not sure of a decent way of presenting this thou off hand.  Would anyone else find this handy?


On Fri, Jun 13, 2008 at 7:03 AM, Cédric Beust ♔ <[hidden email]> wrote:
Hi David,

I just implemented this feature.  You can now declare an Object[] parameter in your @BeforeMethod method and it will be filled with the parameters that are about to be injected into the test method.

Please download:


and let me know if it fixes your problem.

--
Cedric



On Wed, Jun 11, 2008 at 3:43 AM, David R <[hidden email]> wrote:

Is there anyone out there that can point me in the right direction for
what i need to do?
I want to use before and after methods for my code that require the
dataprovider data.

On Jun 5, 1:20 pm, David R <[hidden email]> wrote:
> How do i obtain the value of the actualparameterthat is passed to
> the method?
> If i usebeforeMethodis it there is the IContext and i do not see it?
> Or is my only recourse to use a listener?
>
> My goal is similar to what someone else posted -- that for anyparametersent, i want to use thatparameterin theBeforeMethodto do
> some setup.
> Currently, i need to do all my setup as part of the test.
>
> TIA,
> David





--
Cédric





--
"It is easier to optimize correct code than to correct optimized code." -- Bill Harlan





--
Cédric

--
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 [hidden email].
To post to this group, send email to [hidden email].
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: BeforeMethod parameter values

Ben Mark
Correct, posted the answer in my previous reply,
Thanks again for all replies , 
~Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.