Archived Support Site

This support site is archived. You can view the old support discussions but you cannot post new discussions.

Replacing connection strings in app.config in test projects

nahojd's Avatar

nahojd

19 Mar, 2011 11:07 PM

In my web project, AppHarbor successfully replaces my connection string with the connection string to the AppHarbor database, so that's all and well.

However, I also have a test project with integration tests, which is run on every deploy. Unfortunately, AppHarbor doesn't seem to find and replace the connection string in the app.config file for the test project. It has the same name, and generally looks exactly the same as in the web.config file. Does AppHarbor only replace connection strings in web.config in the web project? And if so, any idea how I should work around this?

  1. Support Staff 1 Posted by friism on 20 Mar, 2011 07:09 AM

    friism's Avatar

    Can I ask which database you would want to use when running unit tests? At any rate, you're not the first user to ask for a database to use when running unit tests. Where wary of adding such a feature, because unit tests really should work on in-memory databases or at least temporary ones.

    Some time ago, I created a project that uses a local file-system-based SQL Server CE database for unit testing. Would that work for your use case?

  2. 2 Posted by nahojd on 20 Mar, 2011 10:00 PM

    nahojd's Avatar

    I would like to run my integration tests against a database that is as similar as possible to the production database, an SQL Server. Since I run all my integration tests in a transaction scope, that I rollback in the end, I could run them against the production database (I don't have that many tests, and they don't take long to run). So that was what I was trying to do in AppHarbor.

    I use Linq to SQL in my application, and while I possibly could make that run against a SQL Server CE database, that somewhat defeats the point of the integration tests, since they won't be testing the actual integration against the database.

    One way to make it work without running against the production database would be if you allowed me to create two SQL Server databases in one application, one for testing and one for production. But for now, I guess I'll just put the production database connection string directly into the test config.

  3. Support Staff 3 Posted by friism on 21 Mar, 2011 03:02 AM

    friism's Avatar

    OK, cool that you have a workaround. We'll keep your use case in mind,

  4. friism closed this discussion on 21 Mar, 2011 03:02 AM.

Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac