Reload app.config with nunit

前端 未结 3 2182
南旧
南旧 2020-12-17 18:52

I have multiple NUnit tests, and I would like each test to use a specific app.config file. Is there a way to reset the configuration to a new config file before each test?

3条回答
  •  心在旅途
    2020-12-17 19:33

    I answered a similar question for Powershell. The same technique should work here, simply call the following at the start of your test:

    System.AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configPath)

    EDIT: Actually looks like this is more complicated within a compiled exe - you need to do something like this in order to get the config reloaded.

提交回复
热议问题