0
votes

I have 2 classes - Class A and Class B - class A containing 2 test methods and Class B containing 1 test method annotated with @Test and priority in TestNG

Class B extends Class A as class B need to use WebDriver object initialized in Class A (in one of the methods annotated with @Test (priority=1))

When TestNG run the tests, it runs both methods of Class A and then runs the method in Class B. And then it runs the 2 methods of Class A again and completes the test

Why does it execute methods of Class A again? How to prevent it from doing this?

1
It would be better if you can share the sample code here for better understanding of the problem you are facing.Harish

1 Answers

0
votes

I wouldn't use a @Test to do the initialisation! Use a @Before method or something like that. If this is a very complex method, then I would try to make it static and reusable or extract it to an abstract class, which both classes (A and B) are extending from.