怎么样在Nunit 中找到config文件

来源:互联网 发布:chrome 插件 知乎 编辑:程序博客网 时间:2024/04/29 01:28

One area that was difficult to figure out relative to NUnit was how to use external configuration files. Normally, you can define a Web.config file for ASP.NET Web applications and application .config files for executables. What can you do when NUnit requires a .DLL assembly and your code has been written to use a configuration file, however? The answer is to create a configuration file for testing.

Recall that NUnit creates an instance of the AppDomain for the .DLL you are testing. One of the other things it does is to manually look for an assembly.dll.config file. Thus, if you need configuration options for your application, copy those settings into a .config file for testing. In our example, such a .config file would be MyMath.dll.config, placed in the same directory as the test DLL loaded by NUnit.

To learn more about AppDomains, assemblies, Reflection, and configuration files, pick up a copy of my new book The Visual Basic .NET Developer's Book from Addison-Wesley (available Spring 2003, ISBN: 0672324075).

原创粉丝点击