开发者

Can an NUnit project load a separate *.config for each assembly that it loads?

If so, how?

If not, what is t开发者_Go百科he best workaround? Particularly, I'm trying to automate running unit tests in the GUI test runner on arbitrary developers' machines.


The best solution is to make the classes you want to unit test accept configuration settings in their constructors rather than read them from configuration files.

Make callers responsible for obtaining configuration data: decouple your classes from specific configuration sources and eliminate hidden dependencies in one fell swoop.


Yes, you can configure NUnit to do this. If you specify domainUsage="Multiple" in your project's settings, it will load .dll.config for each assembly in your NUnit project.

Here's a sample project file with this setting specified:

<NUnitProject>
    <Settings activeConfig="Debug" domainUsage="Multiple" />
    <Config name="Debug" binpathtype="Auto"   >    
      <assembly path="Assembly1.dll" />
      <assembly path="Assembly2.dll" />
    </Config>
    <Config name="Release" binpathtype="Auto" />
</NUnitProject>

In this case, NUnit will load Assembly1.dll.config and Assembly2.dll.config automatically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜