VSTS 单元测试错误,开发机通过 xUnit.net

VSTS Unit Tests Errors, Dev Machine Passes with xUnit.net

所以我们已经处理这个问题一段时间了,但似乎无法找出问题所在。

如标题所述,我们的开发机器可以 运行 在本地进行单元测试没有问题,但是当单元测试在 VSTS 中 运行 时,Microsoft.WindowsAzure.ServiceRuntime.dll 似乎引起问题。

最重要的是,VSTS 的构建代理是我的开发机器,在 Visual Studio 2015 年,运行s 单元测试没有问题...

任何指导都会非常有帮助!

System.TypeInitializationException : The type initializer for *** threw an exception

---- System.TypeInitializationException : The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.

System.TypeInitializationException : The type initializer for '<Module>' threw an exception.

<CrtImplementationDetails>.ModuleLoadException : The C++ module failed to load while attempting to initialize the default appdomain.

System.Runtime.InteropServices.COMException : Failed to load the runtime. (Exception from HRESULT: 0x80131700)

所以我想跟进这件事,以防其他人使用 xunit.net 在 VSTS 中发现同样的问题。

问题主要围绕Visual Studio测试构建步骤中的其他控制台选项/平台:x64

更正后我遇到的下一个问题是这个错误System.ArgumentException : Keyword not supported: 'metadata'.

这是一个误导性错误,因为问题的根源是一些单元测试项目引用了其他单元测试项目的各种辅助方法,并且存在那些 other 测试项目dll 在单独的测试项目中,导致重复发现和重复这些测试项目 运行。将这些助手移动到 Shared 测试项目后,删除对不同测试项目的引用并确保 Shared 测试项目不会 通过在 Visual Studio 测试步骤 -> 执行选项 -> 测试程序集 -:**\xunit.runner.visualstudio.testadapter.dll;-:**\*.Test.Shared.dll;

中输入以下内容,发现 当 运行 VSTS 中的测试

我希望这对其他人有帮助...