--
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 testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/75128be3-65f2-4390-8a24-4dd77b523806%40googlegroups.com.
I don't think its going to be possible.I think TestNG goes from base class to child classes (at least that's how I remember it happening) or maybe the order is non deterministic because of reflection being used [ One of these is true, I can't remember at the top of my head as to which is the one ]You may need to re-think on how you want to do this.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 Scribblings @ https://rationaleemotions.com/
On Thu, Oct 10, 2019 at 10:16 AM Gagandeep Singh <singh....@gmail.com> wrote:
Hi,--I have a Parent class called Parent and a child class called Child, which extends Parent class. Parent class has a method A annotated with @BeforeMethod annotation and child class has a method B which is also annotated with @BeforeMethod annotation. Now, is there a way to stop the execution of method A which is annotated with @BeforeMethod annotation. Here I will explain it with an example:public class Parent {@BeforeMethodprotected void a() {System.out.println("I am inside parent class @BeforeMethod");}}public class Child extends Parent {@BeforeMethodprivate void b() {System.out.println("I am inside child class @BeforeMethod");}}Now, is there a way to stop the execution of parent class BeforeMethod from child class BeforeMethod? or might be using a custom listener?Note: This parent class is also extended by other classes. So, in other cases @BeforeMethod inside the parent class should run as expected but should not run only when child class test are executed.Any help or suggestions would be appreciated. TIA.
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 testng...@googlegroups.com.
@BeforeClass(alwaysRun = true)
@Parameters({"browser", "logInPageUrl", "usernameField", "passwordField", "loginButton", "userMenu"})
protected void invokeBrowserAndLogIn(@Optional("chrome") String browser, @Optional("https://www.xyz.com/") String logInPageUrl,
@Optional("os_username") String usernameField, @Optional("os_password") String passwordField,
@Optional("login") String loginButton, @Optional("admin") String userMenu) {
switch (browser.toLowerCase()) {
case "firefox":
WebDriverManager.firefoxdriver().setup();
driver.set(new FirefoxDriver());
break;
case "ie":
if(!System.getProperty("os.name").toLowerCase().contains("mac")) {
WebDriverManager.iedriver().setup();
driver.set(new InternetExplorerDriver());
} else {
System.out.println("You appear to be running MAC operating system. The IE driver only runs on Windows operating system. Tests not executed. Please review!");
throw new IllegalStateException("You appear to be running MAC operating system. The IE driver only runs on Windows operating system. Tests not executed. Please review!");
}
break;
default:
WebDriverManager.chromedriver().setup();
driver.set(new ChromeDriver());
}
testEnvironment(logInPageUrl);
login(usernameField, passwordField, loginButton, userMenu);
}
@BeforeClass(alwaysRun = true)
@Parameters({"browser", "logInPageUrl", "usernameField", "passwordField", "loginButton", "userMenu", "newParameter"})
protected void invokeBrowserAndLogIn(@Optional("chrome") String browser, @Optional("https://www.xyz.com/") String logInPageUrl,
@Optional("os_username") String usernameField, @Optional("os_password") String passwordField,
@Optional("login") String loginButton, @Optional("admin") String userMenu, @Optional("new value") String NewParameter) {
switch (browser.toLowerCase()) {
case "firefox":
WebDriverManager.firefoxdriver().setup();
driver.set(new FirefoxDriver());
break;
case "ie":
if(!System.getProperty("os.name").toLowerCase().contains("mac")) {
WebDriverManager.iedriver().setup();
driver.set(new InternetExplorerDriver());
} else {
System.out.println("You appear to be running MAC operating system. The IE driver only runs on Windows operating system. Tests not executed. Please review!");
throw new IllegalStateException("You appear to be running MAC operating system. The IE driver only runs on Windows operating system. Tests not executed. Please review!");
}
break;
default:
WebDriverManager.chromedriver().setup();
driver.set(new ChromeDriver());
}
testEnvironment(logInPageUrl);
login(usernameField, passwordField, loginButton, userMenu);
}
I don't think its going to be possible.I think TestNG goes from base class to child classes (at least that's how I remember it happening) or maybe the order is non deterministic because of reflection being used [ One of these is true, I can't remember at the top of my head as to which is the one ]You may need to re-think on how you want to do this.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 Scribblings @ https://rationaleemotions.com/
On Thu, Oct 10, 2019 at 10:16 AM Gagandeep Singh <singh....@gmail.com> wrote:
Hi,--I have a Parent class called Parent and a child class called Child, which extends Parent class. Parent class has a method A annotated with @BeforeMethod annotation and child class has a method B which is also annotated with @BeforeMethod annotation. Now, is there a way to stop the execution of method A which is annotated with @BeforeMethod annotation. Here I will explain it with an example:public class Parent {@BeforeMethodprotected void a() {System.out.println("I am inside parent class @BeforeMethod");}}public class Child extends Parent {@BeforeMethodprivate void b() {System.out.println("I am inside child class @BeforeMethod");}}Now, is there a way to stop the execution of parent class BeforeMethod from child class BeforeMethod? or might be using a custom listener?Note: This parent class is also extended by other classes. So, in other cases @BeforeMethod inside the parent class should run as expected but should not run only when child class test are executed.Any help or suggestions would be appreciated. TIA.
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 testng...@googlegroups.com.
I think you should basically get rid of all parameters in your configuration method and instead just work with native injection wherein you inject an ITestContext object via which you retrieve the parameters map and work with it.
You could perhaps build a utility method which accepts an ITestContext object and returns back various different pojos (one pojo which is common across all tests, and then subclassed pojos which are specific to particular tests).
That should streamline things a lot.
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.com/
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/9a24f157-33b1-4973-8318-0a0f53af33f6%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/HElSfOCXFyg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/DB118C57-EB71-48AC-AB0A-138C1A713535%40gmail.com.
Read more about :
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/CAFV87vM%2BGSGs-VVf9WHrj3TSgM5P8VdZ8mf7B4vzDhU2awzFqA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/07388B11-61E3-478B-BFD0-CC45754A93B5%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/CANikZLnsRkMfe9yNhAzu61fZ%2BFnGzB1X-fTgRZxPOp7UwLi3uA%40mail.gmail.com.
Hi Gagandeep,@BeforeMethod goes from top to bottom i.e. from base class to child class.@AfterMethod goes from child class to parent class.Thanks,Arthi
To unsubscribe from this group and stop receiving emails from it, send an email to testng...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/75128be3-65f2-4390-8a24-4dd77b523806%40googlegroups.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 testng...@googlegroups.com.