集成测试无法加载文件或程序集

时间:2017-06-13 22:05:56

标签: c# asp.net-core integration-testing

我一直遇到xunit集成测试的问题。

Integration Test项目设置为.NET 4.6.1。

Integration Test项目引用了ASP.NET Core(目标net461)项目A.

项目A引用了使用System.Security.Cryptography.X509Certificates, Version=4.1.0.0的.NET标准库,我们称之为项目B.

从我的Integration Test项目创建TestServer时,测试失败并带有

Message: System.IO.FileLoadException : Could not load file or assembly 'System.Security.Cryptography.X509Certificates, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).

但是,单独运行项目A时,它本身不需要引用System.Security.Cryptography.X509Certificates。我假设这是因为项目B已经有了这个参考。

如何确保我的集成测试项目能够解决下游项目的所有依赖项?

0 个答案:

没有答案