In our current team we’re doing a lot of integration testing which means that we need a well known state in the database before each test run. We have solved this with a simple restore of a known backup before each test run (with the handy BeforeTestRun-attribute of SpecFlow). But we have run into some issues…
That means that we destroying the database for each other all the time during development. So we created a small database for each developer and restored that before each test run. But again it jump back and bit us, I wont say where…
The database name and backup name we’re restoring is stored in app.config which means that you need to change that on your local machine. A simple slip on check-in might have you distribute your app.config to the whole team, and we’re back on square one.
I tried to solve this with user settings but that didn’t seem to work for test project. I probably has to do with the fact that a test project is a class library and doesn’t hold a App Domain. It’s MSTest that runs the test so it’s probably MSTest’s config that need to be tweaked.
But we’ve found a simple (and yes, more brute way I agree) to do this:
- I created an app.master.config that contains all the keys and the settings we’re using on test run on the build server.
- I checked in that app.master.config
- I then created an app.config in my own project and changed the keys to my personal settings.
- And then, and here’s the thing, I selected the app.config and went Exclude from project in the Source Control menu.
|Excluding app.config from source control|
This works fine. Is there another way to accomplish the same thing? Please let me know about it.
If you liked this post ... here's more for you:
Published byon Last updated