Matthias Noback has written up an article on his site covering a tool that's common in many web applications, especially for testing: fixture data. In the post he makes some suggestions about effective ways to use them to provide more "real world" results for tests.
System and integration tests need database fixtures. These fixtures should be representative and diverse enough to "fake" normal usage of the application, so that the tests using them will catch any issues that might occur once you deploy the application to the production environment. There are many different options for dealing with fixtures; let's explore some of them.
He makes four suggestions of ways to handle fixtures:
- Generate them the "natural" way via interaction with the application and taking a snapshot of the data.
- Generate them at runtime for the tests, reloading them each time
- Manual insertion of custom data into the database for all tests
- Manual insertion of custom data into the database for each test case
He finishes the post by asking a question for those considering using fixture data: do you need them at all? Testing should be isolated from external sources so maybe they're not really needed...