running a config before and after a specific test (not all)

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

running a config before and after a specific test (not all)

Satyam Jaiswal
I'm wondering if there is a way to run a method before and after a specific test in a class?
I'm aware of @BeforeMethod and @AfterMethod that run before and after each test method in the class but that is not what i'm looking for.

--
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: running a config before and after a specific test (not all)

Krishnan Mahadevan

TestNG supports something called as Native Injection.

 

So you can have TestNG inject a java.lang.reflect.Method object which you can inspect to see if it’s the method that you need and if it is, then you execute your setup/tear down.

 

 

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/

 

From: 'Satyam Jaiswal' via testng-users <[hidden email]>
Reply-To: <[hidden email]>
Date: Saturday, May 26, 2018 at 1:08 PM
To: testng-users <[hidden email]>
Subject: [testng-users] running a config before and after a specific test (not all)

 

I'm wondering if there is a way to run a method before and after a specific test in a class?

I'm aware of @BeforeMethod and @AfterMethod that run before and after each test method in the class but that is not what i'm looking for.

--
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: running a config before and after a specific test (not all)

ROHIT KUMAR
HI.
You can use @AfterClass annotation.

Thanks!! 
With Warm Regards, 
Rohit Kumar
(FSPL001147)
Software Tester
Franciscan Solutions Pvt. Ltd.
Ext no:- 230

(
4th Floor, Tower-IT/ITES,
STELLAR BUSINESS PARK,
​ ​
Plot No
​.​
​ TZ​
0​
3,
​ Sec.-​
Tech Zone,
Greater Noida, Uttar Pradesh
​- ​
201308
​)​
www.franciscansolutions.com




On Sat, May 26, 2018 at 1:25 PM, Krishnan Mahadevan <[hidden email]> wrote:

TestNG supports something called as Native Injection.

 

So you can have TestNG inject a java.lang.reflect.Method object which you can inspect to see if it’s the method that you need and if it is, then you execute your setup/tear down.

 

 

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/

 

From: 'Satyam Jaiswal' via testng-users <[hidden email]>
Reply-To: <[hidden email]>
Date: Saturday, May 26, 2018 at 1:08 PM
To: testng-users <[hidden email]>
Subject: [testng-users] running a config before and after a specific test (not all)

 

I'm wondering if there is a way to run a method before and after a specific test in a class?

I'm aware of @BeforeMethod and @AfterMethod that run before and after each test method in the class but that is not what i'm looking for.

--
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.

--
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: running a config before and after a specific test (not all)

Satyam Jaiswal
In reply to this post by Krishnan Mahadevan
Thanks Krishnan!
But this approach wouldn't necessarily run the method after the test. In case there is an assertion failure or an exception occurs then the method execution might be skipped.

On Saturday, May 26, 2018 at 12:56:10 AM UTC-7, Krishnan Mahadevan wrote:

TestNG supports something called as <a href="http://testng.org/doc/documentation-main.html#native-dependency-injection" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Fdoc%2Fdocumentation-main.html%23native-dependency-injection\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGezhC1wUSDaui0PSu9qt8csftgTA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Fdoc%2Fdocumentation-main.html%23native-dependency-injection\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGezhC1wUSDaui0PSu9qt8csftgTA&#39;;return true;">Native Injection.

 

So you can have TestNG inject a java.lang.reflect.Method object which you can inspect to see if it’s the method that you need and if it is, then you execute your setup/tear down.

 

 

Thanks & Regards

Krishnan Mahadevan

 

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

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: 'Satyam Jaiswal' via testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ahYR7e2PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ahYR7e2PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Saturday, May 26, 2018 at 1:08 PM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ahYR7e2PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: [testng-users] running a config before and after a specific test (not all)

 

I'm wondering if there is a way to run a method before and after a specific test in a class?

I'm aware of @BeforeMethod and @AfterMethod that run before and after each test method in the class but that is not what i'm looking for.

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ahYR7e2PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ahYR7e2PBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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: running a config before and after a specific test (not all)

Krishnan Mahadevan
It should provided you add always run=true for your teardown configuration method. 

On Tue 29 May, 2018, 11:31 'Satyam Jaiswal' via testng-users, <[hidden email]> wrote:
Thanks Krishnan!
But this approach wouldn't necessarily run the method after the test. In case there is an assertion failure or an exception occurs then the method execution might be skipped.

On Saturday, May 26, 2018 at 12:56:10 AM UTC-7, Krishnan Mahadevan wrote:

TestNG supports something called as Native Injection.

 

So you can have TestNG inject a java.lang.reflect.Method object which you can inspect to see if it’s the method that you need and if it is, then you execute your setup/tear down.

 

 

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/

 

From: 'Satyam Jaiswal' via testng-users <[hidden email]>
Reply-To: <[hidden email]>
Date: Saturday, May 26, 2018 at 1:08 PM
To: testng-users <[hidden email]>
Subject: [testng-users] running a config before and after a specific test (not all)

 

I'm wondering if there is a way to run a method before and after a specific test in a class?

I'm aware of @BeforeMethod and @AfterMethod that run before and after each test method in the class but that is not what i'm looking for.

--
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.
--

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 [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.