visual-studio-2010 - 为什么VS2010不把/bin/debug中的所有DLL都复制到单元测试目录下?

标签 visual-studio-2010 unit-testing mef

我有一个单元测试,它依赖于一些使用 MEF 的代码。当我运行测试时,MEF(我相信)MEF 尝试加载单元测试执行目录中所有 DLL 的所有依赖 DLL。

问题是 VS2010 由于某种原因没有将/bin/debug 目录中的所有 DLL 复制到单元测试的执行目录中,我不知道为什么。下面是一个例子:

单元测试提示无法加载程序集 A,所以我包含了程序集 A 作为依赖项的项目 B。在单元测试项目的/bin/debug 文件夹中,所有 DLL 都在那里,但是当我查看单元测试的执行目录时,程序集 A 不在那里。

我可以开始一个一个地将 DLL 添加为单元测试项目的引用,但我觉得我应该这样做。

想法?

谢谢,
标记

最佳答案

也许 DeploymentItem 属性可以提供帮助,http://msdn.microsoft.com/en-us/library/ms182475.aspx :

For the parameter of the DeploymentItem attribute, specify the folder or file that you want to deploy for this test. You can use either an absolute path or a relative path. Relative paths are relative to the RelativePathRoot setting found in the .testrunconfig file.


[TestMethod]
[DeploymentItem("MyTestProject\\testdatasource.mdb")]
public void TestMethod1()
{

// TODO: Add test logic here

}

关于visual-studio-2010 - 为什么VS2010不把/bin/debug中的所有DLL都复制到单元测试目录下?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6309973/

相关文章:

Xamarin 和托管可扩展性框架 (MEF)

asp.net - 将 UNIqueIdentifier 传递给另一个 ASP.NET 页面

c++ - 简单的客户端/服务器在传输中丢失线路 (boost/Windows)

visual-studio - 在 Visual Studio 2010 中开发和单击 CTRL 时进行实时编译器检查?

java - 使用hamcrest匹配Map包含不同类型的条目

unit-testing - 为什么即使测试失败,我的 Sonar Jenkins 工作也永远不会变得不稳定?

visual-studio-2010 - Visual Studio 2010双击以选择空白过于激进

android - 如何在 Android 上对 SharedFlow 进行单元测试

.net - 将数据编入/编出插件的最佳方法是什么?

C# MEF : Exporting multiple objects of one type, 和导入特定的