gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 20:21:16 25 4
gpt4 key购买 nike

我有一个单元测试,它依赖于一些使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com