Currently, I am in charge of developing a blackbox automated testing framework using C# and Selenium web driver and using this framework to automate our current manual regression suite. The system under test is an ASP.NET web application.
Each test may rely on a complex aggregate of data. For example, to test the creation of an 'activity', a 'client' must be present with a 'service' against which the 'activity' is to be created.
How should data required for such a test be managed? Should the test assume it to be present? In this case, the test would simply create the activity. Or, should the test create the requisite data? In this case, the test would create the client, create the service, then create the activity.
We're thinking of the following potential solutions and are debating the merits of each:
- db is blank, test creates data as needed, db is wiped after each test
pro: test and data are together, tests can not affect each other
con: long run time, more complex tests
- db is blank, fixture creates data needed for all tests, db is wiped after each fixture
pro: test and data are close
con: tests within a fixture can effect each other
- db is populated with requisite data, tests assume requisite data is present
pro: faster run time
con: test and data are separate. Tests more likely to affect each other
Which, if any of these approaches is considered best practice? If none of the above, what approach is considered best practice?