|
|
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.
|
|
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 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='http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Fdoc%2Fdocumentation-main.html%23native-dependency-injection\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGezhC1wUSDaui0PSu9qt8csftgTA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Fdoc%2Fdocumentation-main.html%23native-dependency-injection\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGezhC1wUSDaui0PSu9qt8csftgTA';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='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ';return true;">http://wakened-cognition.blogspot.com/ My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ';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='javascript:';return true;" onclick="this.href='javascript:';return true;">testng...@...> Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ahYR7e2PBgAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';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='javascript:';return true;" onclick="this.href='javascript:';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='javascript:';return true;" onclick="this.href='javascript:';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='javascript:';return true;" onclick="this.href='javascript:';return true;">testng...@.... Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/group/testng-users';return true;" onclick="this.href='https://groups.google.com/group/testng-users';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='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';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.
|
|
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.
--
--
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.
|
|