The problem with NUnit and app.config

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

    1. Go to NUnit/Project/Edit...
    2. In Configuration Property panel go to Configuration File Name
    3. Put there yourAssemblyName.dll.config

    NB: if does not work try to add path to it, e.g. bin\Debug\ yourAssemblyName.dll.config

    Your test project file yourAssemblyName.nunit will be updated.

    And yes, be sure App.config in your test project match to what you access in test, i.e.

    [Test]
    public void TestConn()
    {
       var sss = ConfigurationManager.AppSettings["TestKey"];
    }
    

    App.config

    
    
      
        
      
    
    

提交回复
热议问题