单元测试的 Web.Config 问题

发布于 2024-08-30 07:50:16 字数 198 浏览 1 评论 0原文

我正在尝试对很多 MVC 控制器进行单元测试,但不幸的是它一直失败,因为它需要 web.config 中的大量设置..

我复制了但没有读取它,我需要的是成员资格和 rolemanager,但我也不能将其添加到 app.config 中,我已经能够获取要使用的连接字符串和应用程序设置。

知道如何让 web.config 与 MSTest 一起使用吗?

I am trying to unit test a lot of my MVC controllers, but unfortunately it keeps failing because it needs a lot of settings from the web.config..

Which I copied over but does not read it, what I'm needing is the membership and rolemanager but I can't just add it to the app.config either, which I've been able to get the connection strings and application settings to work with..

Any idea how to get the web.config to work with MSTest?

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

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

发布评论

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

评论(2

还不是爱你 2024-09-06 07:50:16

这个问题的一半已经在另一篇文章中得到了回答 - 在没有 ASP.NET 的情况下测试会员提供程序< /a>.应该可以使用相同的范例来测试角色管理器。

注意:我认为,要求通过配置文件检索设置(包括 asp.net 成员资格和角色管理器提供程序)以执行测试意味着您正在编写集成测试而不是单元测试。

Half of this question has already been answered in another post - Testing Membership provider without ASP.NET. Testing the rolemanager should be possible using the same paradigm.

Note: requiring settings (including the asp.net membership and rolemanager providers) to be retrieved via a config file for test execution means you are writing integration tests instead of unit tests my opinion.

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