Pre-load database for testing
I'm a bit new to mocking data for testing. I'm using ruby in conjunction with watir-webdriver and I have a local version of the app. I'd like to run a script which empties the tables of the local database, and then preloads with defined values so that the browser integration suite can run and check for expected values. The problem is that I have no idea how to start.
I think i will use a
pggem. But I'd like the data to be the same every test run, so I'd rather not have a data generator, so It looks like scripts are the way to go, but I have no idea what the best practices are around this or what it should look like.
In Linux you could write a bash shell script to load a database so you are at a known place for your testing. In windows you could use PowerShell to do it quite easily for MS SQL. There should be automation options for all the mature databases. As you don't specify your OS or database more specific help is unlikely.
A sane thing you might consider doing depending on how you deploy your app is to write a set of scripts to create the database schema and then populate it with your expected initial data, following that you would run the script to populate the extra data that you need for test. This tests your generation of your database (if you need this sort of testing).