是否有更强大的方法来集成测试我的持久层 app.config?

发布于 2024-08-22 02:52:22 字数 645 浏览 1 评论 0原文

我的应用程序分为以下项目/程序集

  • Approot/UI
  • AppDomain/业务逻辑/层
    • 域.测试
  • 持久化/数据库层
    • 持久性测试

我正在使用 MSTest 对存储在 Persistance 程序集中的连接字符串进行集成测试。目前我正在使用 LocalTestRun.config 作为解决方案,告诉它包含持久层的 app.config 文件进行测试,但我想如果任何其他层在其测试部分中有 app.config 文件,这将无法正常工作。这应该如何设置? ConfigurationManager.GetSection(程序集名称?)

添加 [DeploymentItem("app.config")] 对测试方法有什么作用?

    [TestMethod]
    [DeploymentItem("app.config")] // I added this to see if it would help somehow
    public void Configuration_ConnectionStrings_Connect()
    {
    //code omitted
    }

I have my application broken into the following projects/assemblies

  • Approot/UI
  • AppDomain/business logic/layer
    • Domain.Tests
  • Persistance/db layer
    • Persistance.Tests

I'm integration testing the connection string stored in the Persistance assembly using MSTest. currently I am using LocalTestRun.config for the solution to tell it to include the Persistance layer's app.config file for testing, but I imagine this will not work well if any other layers have an app.config file in their test sections. How is this supposed to be set up? ConfigurationManager.GetSection(assemblyName?).

What does adding [DeploymentItem("app.config")] do for the test method?

    [TestMethod]
    [DeploymentItem("app.config")] // I added this to see if it would help somehow
    public void Configuration_ConnectionStrings_Connect()
    {
    //code omitted
    }

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文