reading values from config files in NUnit tests RRS feed

  • Question

  • User65893105 posted

    One of my NUnit tests has to read in some values from config files.  In my main application this process works perfectly well, however when I run the unit test, the code that reads in the values from the config files doesnt read anything in.  Ive tried putting app.config in my unit test project (I even tried web.config) but nothing seems to work.  Are there any special steps involved when reading from config files in an nunit test ?

    Wednesday, August 18, 2010 4:07 AM


  • User-1802908944 posted

    no need to worry.

    add a public property in your appliction and assign it to value from config file and use like in NUnit

        public class MyClassFixture

            Myclass iobjMyclass = new Myclass();

            public void GetProgramDetail()
                  string strPublic = iobjMyclass.PublicProperty;

                 //// and use strPublic

                catch (Exception ex)
                    throw new Exception(ex.InnerException.ToString());


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 18, 2010 6:08 AM