So I have the following code snippet:
@BeforeTest
public void setup() throws MalformedURLException {
driver = SetupUtil.getAndroidDriver(ConstUtil.DEFAULT_DEVICE);
groupPage = new GroupPage (driver);
}
In every test I call this method to initialize the driver and an appropriate page factory object. On the driver initialization I use Singleton pattern (if the driver has already been created, I do not create it again). Page object I just initialize anew in each test.
Is it a right practice to do so? Or is there a better way? Please advice.
The thing is, for example, when I have 3 test classes related to the group testing (CreateGroupTest, GroupActionsTest (adding, deleting members, change title etc.) DeleteGroupTest), in every one of them I initialize the Group page factory object anew. However, I could use singleton instead and have only one instance created for all of these test classes. Or it doesn’t matter?
Anyway, your advice on the code snippet please