2

I want to run some unittests. For this tests I need to use another value from the app.config file then the default value.

In this post "Reload app.config with nunit", I found a solution.

However when running multiple test at once, some test fail, because the old configuration file (app.config) is not called after disposing the function. How could this be ?

Community
  • 1
  • 1
Jan
  • 9,858
  • 7
  • 26
  • 33
  • 3
    Commenting because this is not an immediate solution to your question: I always create a 'configuration provider' class to wrap access to the app.config file so that I can mock out the configuration in unit tests without having to worry about changing any files. You might want to consider this for a design change in you application. – Dr Herbie Aug 24 '10 at 07:00

2 Answers2

7

Did you think of wrapping access to the configuration settings in a class? This way you could mock configuration settings in your tests either by using some mocking framework or by creating your own mocks.

Fredrik Mörk
  • 155,851
  • 29
  • 291
  • 343
  • Thanks for the answer but this is not really a solution for my question. I dont't want to change my code just for testing purposes. – Jan Aug 24 '10 at 11:15
0

I did not found a good solution but for now I use another test project which uses a different app.config

Jan
  • 9,858
  • 7
  • 26
  • 33