I am writing automated functional tests for my application. To interact with the application, I use the SQL database to retrieve data and validate data.
The main challenge that I am facing is handling the test data for my tests. I need to access the database to be able to retrieve test data, which may get updated every build. Afterwards, I use that test data for logging in, or navigating to a specific page, or for validations to make sure that what I am doing on the UI is appropriately represented in the back end.
I could hit the database multiple times throughout a test to be able to perform a specific action. The problem is that some of these queries are taking 5 minutes in order to execute, significantly slowing down my test execution and making it unnacceptable.
Therefore, I would appreciate advice on how to handle such a situation.
- Is there an appropriate design pattern that I should use?
- Should I execute all my queries up front and store their results somewhere and then use them for all my tests?
- Should I execute these queries externally, build a test table, and then use that for my testing instead?
- Or is there something better that you can suggest?
More details based on questions:
My application is allows a user to take an exam. In order for me to properly test a single question in the exam, I need to execute a query that finds this question in the DB. Afterwards, I need to find this question in an exam booklet that is assigned to a number of fake student IDs. Therefore, what I have to do is get this student ID to be able to login to the application to test this particular question. Getting this data to be able to login to the appropriate question is the time consuming part.