The problem with NUnit and app.config

前端 未结 9 769
孤独总比滥情好
孤独总比滥情好 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:32

    I was in the same situation and I tried to add app.config to NUnit project but the project couldn't identify it. The tricky workaround for me was to create a class library that contains an app config and turn in into my test project. At the end of the day, all NUnit and its adapter are NuGet packages that can be added for tests to a class library and tests work perfectly fine ran by Visual Studio and Resharper.

    And finally debugged my test and received the value from App.config file within my test project:

提交回复
热议问题