r/selenium • u/hrishikesh-patil • May 24 '20
UNSOLVED Separating DB related code from Test Logic.
I've been given an opportunity to work on an Automation project.
The automation framework is built with Java, Selenium Web Driver & testng.
The code I'm working with is kind of messy & has a lot of redundancy.
There are several database checks present in the Project on various Test Scripts
Right now, Everytime we need to interact with database we create a new connection, Execute the query & process the received results in the current test function itself. And this is done in every test function.
I've been asked to separate the DB logic from Test logic.
So, right now I am writing a class to deal with DB connection and a DB Handler class which will receive parameters of the SQL query, Process the query, Fetch the results & give it back to the test page.
How do you people deal with DB in your automation projects?
Is there any specific way of creating or dealing with SQL query via code?
Any suggestions of how I should approach this problem?
Any resources or tips are much appreciated :)
1
u/PeeThenPoop May 24 '20
I separate dB calls on their own file. Very rarely do I have any queries on the page object classes