I am trying to setup a test database for automated tests to run against. I know ideally we should be using mock objects, but this is an old app and doing so isn't as easy as it should be. There's simply too much logic in the database.
Anyhow, enough backstory. I'm getting a clean db setup that the tests can load with known data so that results are thus known as well.
At the start of the test, a .sql script will be run to empty the tables and then fill them with test data. The problem I see, is not so much keeping the database structures in sync, as they don't change much (though that would be nice too) but to move all the procs/functions etc across from dev into test at the start of the test.
Is there SQL commands that can be executed to do this? To read a proc from the dev db, and copy it to the test db?
EDIT: I've actually found that using SQL Management Objects works pretty good.
The only problem is that if someone renamed an item, internal references aren't updated by sql server, and it's created under the old name. Is there a way to fix this?