.net - Microsoft单元测试失败,无法加载DLL进行测试

标签 .net unit-testing

我有一个 .NET 3.5 类库,我正在尝试为其编写一些自动化测试,但在解决方案中运行任何测试时出现以下错误:

Test method Common.Tests.CommonTests.TestMethod1 threw exception: System.IO.FileNotFoundException: Could not load file or assembly 'Library.Common, Version=0.0.1.22004, Culture=en-AU, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.WRN: Assembly binding logging is turned OFF.

To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

Note: There is some performance penalty associated with assembly bind failure logging.

To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

我对单元测试还很陌生,所以我很困惑。

我比较了 lib 和测试项目之间的引用,唯一的区别是测试项目引用了 MS 单元测试 DLL。

编辑以澄清

我在“Library.Common”项目中使用了测试创建向导,因此测试项目引用了 Library.Common 项目。我也清理并构建了解决方案,这不是问题。

Library.Common.dll 也在我的测试项目输出的 bin\Debug 文件夹中。

最佳答案

发现问题,我在 Library.Common 项目的 AssemblyInfo.cs 文件中设置了 AssemblyCultureAttribute。一旦删除它,测试就会运行。

现在实际学习如何使用该属性!

关于.net - Microsoft单元测试失败,无法加载DLL进行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/199702/

相关文章:

c# - ServiceCollection 不包含来自 "AddLogging"的定义

c# - RabbitMQ IModel.Dispose 挂起

c# - Async TestInitialize 保证测试失败

c# - 使用 EasyNetQ.Hosepipe 时有没有办法指定不同的错误队列?

android - Koin DI Android 单元测试 ViewModel

javascript - 如何使用 BDD Javascript 测试数组元素类型?

unit-testing - Grails 2.x中的Grails单元测试失败

java - 如何在 Java 中解析 .net DataSet?

.net - 单元测试数据访问层

python - 如何编写单元测试来查看属性是否设置为indexed=False?