How to use web.config when unit testing an asp .net application

后端 未结 6 1279
我寻月下人不归
我寻月下人不归 2020-12-08 01:55

I am starting out with unit testing, I have a method that uses the web.config for a connection string.

I was hoping to be able to use

[DeploymentItem         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 02:02

    You will want your results to be well-defined and repeatable. To to this, you'll need to be working against known data so that you can clearly define both your normal cases and your boundary cases. In my work, this is always a specific server and dataset so the Unit testing module has the connection string built in. Others prefer using a connection string out of the Unit Testing project. I've never seen anyone recommend the use of the web site's config file! (development or otherwise)

提交回复
热议问题