Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个自定义配置部分,我正在为它构建一些单元测试。我希望能够以某种方式以编程方式指定不同的 .config 文件进行测试。有没有办法做到这一点?
我不知道你的单元测试到底是什么样的。如果您的自定义配置所在的单元测试项目中有一个 app.config 文件,则可能的解决方案是以可写模式打开配置并根据需要更改配置值。单元测试后,恢复旧的配置值。
利用
ConfigurationManager.OpenExeConfiguration(...)
另请参阅
如果您正在寻找可单元测试的配置解决方案,请尝试DslConfig