The problem with NUnit and app.config

前端 未结 9 867
孤独总比滥情好
孤独总比滥情好 2020-12-29 19:48

When i run a simple test on connection to DB check i receive an error in NUnit:

[Test]
public void TestConn()
{
    string  connectionString = Configuration         


        
9条回答
  •  被撕碎了的回忆
    2020-12-29 20:33

    Your unit tests should still work as long as you have the same configuration for your test project as for your main project.

    I'd suggest using a pre-build event in your test project to copy your application's configuration file over to the test project. This saves having to maintain two sets of configuration.

    copy $(SolutionDir)path-to-main-project\Web.config $(ProjectDir)App.config

提交回复
热议问题