I am developing a Selenium Test Automation Framework for the purpose of testing multiple websites.

I have currently set up the Framework in Visual Studio using C# and implementing the Page Object Model.

The Framework itself is a C# project and the Test project is separate but references the Framework.

I am happy with the fundamentals of the Framework but I want to implement some Data Driven aspects in order to increase the durability of the tests. I currently have NUnit running paramaterised test using [TestCase] but the data is hardcoded by me.

The ideal scenario would be to add a DatabaseHelper class to the Framework which would allow me to define queries on the database under test to return values and Nunit would repeat the same test for each row of the SQL query.

Has anyone here implemented a similar method and how would you go about creating it?

1 Answer 1


This is quite regular feature for such kind of test frameworks. You need to consider the following:

  • Proper connectivity library to your particular database
  • The way how you're going to store credentials. Do not store passwords in to code. One of the possible solutions is to fetch the creds from environment variables
  • How you manage the connections. Consider using database connection pools otherwise you can eat up all the available connections and either make your other tests fail or other people wouldn't be able to connect
  • How you prepare and then reset test data.
  • If it will make sense for your particular case to deploy some stored procedures to simplify your code on C#
  • If it will make sense not to use direct queries but rather ORM approach.

This is the basic issues you should think of before start implementation of your database integration.

  • Thanks for taking the time to reply. If we have a dedicated database for test data and run the tests at night, not currently in parallel but maybe in future, is point 3 likely to be less of a problem? We will prepare the data and then reset it all via a snapshot on completion of the test suite. Do you have an example of exactly how Nunit reads from a datasource query? [TestCase, typeof(datasource)] Do you have any online examples of Selenium with Nunit and an ORM framework? Oct 12, 2018 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.