c# - 在 Visual Studio 中出现 "Run All"时单元测试失败但单独通过

标签 c# unit-testing visual-studio-2012 moq

我在 MOQ 单元测试中遇到了这个奇怪的问题。

我在 VS 2012 中使用 MOQ 框架编写了大约 636 个单元测试。 当我按项目和/或单独运行它们时,它们成功通过。但每当我选择 Run-All 时,它们都会随机失败并显示不同的错误。

大多数方法显示 IO.FileNotFoundException。

我看了Here herehere但还没有线索。

已编辑:

我使用 DeploymentItem[] 属性解决了 FileNotFoundException 的问题。

但是当 RunAll 时,仍然有一个项目失败了。异常告诉 - “无法转换,类型不兼容”的属性。

最佳答案

似乎我错过了对每个单元测试类使用 DeploymentItem["NeededProject.dll"]。 它现在工作正常。 :)

关于c# - 在 Visual Studio 中出现 "Run All"时单元测试失败但单独通过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28189066/

相关文章:

c# - 将 Azure IoT Edge EFlow 端口公开给主机 (Windows)

c# - 从另一个 Windows 服务启动和停止一个 Windows 服务

c# - 无法加载测试程序集 '*.dll'。错误详细信息 : Could not find file *. dll'

unit-testing - `go test` CLI 测试报告者的推荐

c++ - 在编译时使用 CRC32 算法对字符串进行哈希处理

visual-studio-2012 - Visual Studio 的与语言无关的项目类型?

c# - DotCover 不覆盖引用的 DLL

ruby-on-rails - 了解 Rails 单元测试 : Is it still a unit test if a single test tests model interdependencies?

visual-studio - 调试针对 Framework 4.0 的项目时加载 Framework 4.5 程序集

c# - 在提示框内添加标签