在TFS构建期间,使用Fakes分析代码的代码覆盖率失败 [英] Analyzing Code Coverage on code using Fakes fail during TFS build
问题描述
在我们的TFS构建过程中启用代码覆盖后,我遇到了一些问题。被测试的解决方案包含三个测试项目,而在209个测试中,三个测试失败(一个项目一个,另一个项目两个),并显示以下错误:
I am having some problems after enabling Code Coverage during our TFS builds. The solution under test contain three test projects and out of 209 tests three tests fail (one in one project and two in another), with the following error:
Test method MyNamespace.MyTest threw exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Unexpected error returned by SetDetourProvider in profiler library 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\14.0.0\Microsoft.IntelliTrace.Profiler.14.0.0.dll'.
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.Initialize()
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
MyNamespace.MyTest () in MyFile.cs: line 224
堆栈跟踪指示已连接到Shims的使用。即使在运行代码覆盖率并在构建期间禁用代码覆盖率时,所有测试也会在本地通过,从而使测试再次通过。
该问题似乎与> Fakes生成了UnitTestIsolationException 略有关系,但未安装Resharper
The stack trace indicates that is connected to the use of Shims. All test pass locally even when running Code Coverage and disabling Code Coverage during build makes the tests pass again. The issue seems slightly related to Microsoft Fakes generates UnitTestIsolationException, but Resharper is not installed on the build servers.
我尝试过的操作:
- 不同的生成类型:生成vNext,使用自定义模板或默认模板进行XAML生成
- 使用
/ p:EnableIntelliTrace = true $ c $明确禁用IntelliTrace c>和.runsetting
- 为所有.fakes文件添加了
Diagnostic = true
- 提高日志记录详细程度以获取更多错误信息
- 通过命令行在服务器上本地运行测试
- Different build types: Build vNext, XAML Build with customized or Default Template
- Explicitly disabled IntelliTrace using
/p:EnableIntelliTrace=true
and .runsetting - Added
Diagnostic="true"
to all .fakes files - Increased Logging Verbosity to get more error information
- Run the tests locally on the server through command line
我的构建服务器设置:
- Windows Server 2012 R2
- Team Foundation Server 2015.3
- Visual Studio Enterprise 2015.3
我遇到了同样的错误消息,尽管在我自己的情况下是在运行测试时。从命令行执行时,vstest.console.exe可以正常工作,但是从Bamboo构建任务运行时,它失败并显示上述消息。
I struggled with the same error message, though in my case it was when running the tests themselves. When executed from the commandline, vstest.console.exe worked flawlessly, but when run from a Bamboo build task, it failed with the message above.
问题最终出在用户运行任务-构建服务器使用SYSTEM用户。当我以普通特权用户身份运行任务时,它成功了。
The problem was ultimately the user running the task - the build server used the SYSTEM user. When I ran the task as a normal privilege user, it succeeded.
这篇关于在TFS构建期间,使用Fakes分析代码的代码覆盖率失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!