修改测试装置的 Web 配置

发布于 2024-09-25 19:31:13 字数 255 浏览 1 评论 0原文

我正在使用 CassiniDevLib 托管 MVC 应用程序以进行集成测试。

为了做到这一点,我需要修改 Web 服务器上的一些配置设置,以便它们匹配集成测试环境,第一个是连接字符串,以便它指向测试数据库。

我知道我可以拥有 web.config 文件的两个副本并重命名它们,但我想知道是否有更优雅的方法。即作为测试夹具设置的一部分修改代码中的设置的方法。挑战是我需要从我的测试图进程访问 Web 服务器进程,

如果对此有任何想法,我将不胜感激。

I'm using CassiniDevLib to host an MVC app for integration testing.

In order to do it I need to amend some config settings on the web server so they match the integration testing environment, first one being the connection string so it points to the test database.

I know I can have two copies of the web.config file and rename them but I was wondering if there was a more elegant way. ie a way to amend the settings in code as part of the Test Fixture setup. The challenge being that I need to access the web server process from my test ficture process

Would appreciate any thoughts on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪推晚风 2024-10-02 19:31:13

我假设您使用的是 Visual Studio 2010。其中,您有一个称为“配置转换”的功能。基本上每个构建环境都可以有多个配置文件。您可以拥有自己的自定义构建环境。您可以通过转到配置管理器并添加新配置来获得新配置。

http://blogs .msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx

如果您需要更多示例,您可以在 Internet 上搜索配置转换。

I assume that you are using Visual Studio 2010. In that, you have a feature called as Config Transforms. Basically you can have multiple config file for each build environment. You can have your own custom build env. You have a new one by going to Configuration Manager and adding a new one.

http://blogs.msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx

you can search on the internet for Config Transforms, if you need more examples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文