mstest 不会复制项目中引用的库,而是仅在运行时使用
我有一个使用 Microsoft Enterprise Library 并使用配置来指定缓存管理器类型的项目。
以这种方式加载的缓存管理器依赖于一个库Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
,它包含在我的测试项目中作为参考,但是该库<代码不直接使用(在编译时)。因此,编译后的 mytests.dll 将不会引用该库(使用 dotpeek 验证了这一点)。
问题#1:为什么 MSTest 不将此类库复制到临时文件夹中进行测试? 问题#2:有一个优雅的解决方法吗?
不是优雅的解决方案#1:对包含的库进行虚拟引用(如前所述在此线程中);
或解决方案#2:使用 MSTest Deploy 配置显式包含该库。
解决方案#3:
即使部署选项已关闭,在 mstest 中使用 .testsettings 文件也可以解决该问题。即 testsettings 文件包含:
<Deployment enabled="false">
</Deployment>
似乎这样做会导致 mstest 不在临时 TestResults\user_HOST 2011-12-21 15_22_08\Out
目录中运行,而是在 bin\Debug
中运行> (相关库正确部署到的位置)。
这是 mstest 的预期行为吗?我的意思是,如果在 .testsettings 文件中禁用部署,mstest 不会使用临时目录?
I have a project that uses Microsoft Enterprise Library and uses configuration to specify a type for caching manager.
Loaded in this manner caching manager depends on a library Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
which is included in my test project as a reference, but the library is not being used by code directly (at compile time). As such the compiled mytests.dll will not have that library referenced (verified this using dotpeek).
Question #1: Why doesn't MSTest copy such library to the temp folder for testing?
Question #2: Is there an elegant workaround?
Not elegant solution #1: do a dummy reference to the included library (as mentioned in this thread);
or solution #2: use MSTest Deploy configuration to include the library explicitly.
solution #3:
Using a .testsettings file in mstest resolves the issue even if deployment option is turned off. I.e. testsettings file contains:
<Deployment enabled="false">
</Deployment>
Seems like doing this causes mstest to be ran not in the temp TestResults\user_HOST 2011-12-21 15_22_08\Out
directory, but in the bin\Debug
(where the library in question is correctly deployed to).
Is this an expected behavior of mstest? I mean the fact that mstest does not use temp directory if Deployment is disabled in the .testsettings file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论