开发者

cannot load web.config in mstest

开发者 https://www.devze.com 2022-12-18 05:31 出处:网络
I need read connection string from web.config which in asp.net mvc project, but all i get are null. how can i obtain connection string in mstest, do i need a开发者_如何学Cdditional configuration in so

I need read connection string from web.config which in asp.net mvc project, but all i get are null. how can i obtain connection string in mstest, do i need a开发者_如何学Cdditional configuration in some where?


You can include the web.config file as part of the test project output by including the deployment item attribute in your test class:

[TestClass()]
[DeploymentItem("Web.Config")]
public class myClassTest
{
}

Then you should be able to retrieve your connection string as usual in the class you are trying to test:

0

精彩评论

暂无评论...
验证码 换一张
取 消