编码的UI抛出"无法加载一个或多个请求的类型"

Cal*_*ale 5 coded-ui-tests visual-studio-debugging visual-studio-2017

我无法让Coded UI调试工作.Visual Studio不会在断点上停止.一个简单的演示测试(仅在Excel工作表单元格中输入一个数字)在没有调试的情况下运行时会成功.但是在调试测试时,测试运行器会立即出错,而不会尝试进入测试类构造函数(如果提供)或测试方法.

报告的错误是:

Message: Unit Test Adapter threw exception: 
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..
Run Code Online (Sandbox Code Playgroud)

我正在运行Visual Studio 2017,版本15.5.0.

Debug窗口的输出:

'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CoreUtilities.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.PlatformAbstractions.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CrossPlatEngine.dll'. Cannot find or open the PDB file.

...

'QTAgent32_40.exe' (CLR v4.0.30319: TestAppDomain: 0bb1983f-0f53-41cc-b4ed-143874102a64): Unloaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll'
'QTAgent32_40.exe' (CLR v4.0.30319: TestAppDomain: 0bb1983f-0f53-41cc-b4ed-143874102a64): Unloaded 'C:\VST\CodedUITestProject2\TestResults\abcdef_X#XXX## 2017-12-05 11_05_06\Out\CodedUITestProject2.dll'
The thread 0x1860 has exited with code 0 (0x0).
The thread 0x1dcc has exited with code 0 (0x0).
Exception thrown: 'System.Threading.ThreadInterruptedException' in mscorlib.dll
The thread 0x1cb0 has exited with code 0 (0x0).
The thread 0x2d54 has exited with code 0 (0x0).
The thread 0x2a40 has exited with code 0 (0x0).
The thread 0x1e04 has exited with code 0 (0x0).
The program '[8104] QTAgent32_40.exe: Program Trace' has exited with code 0 (0x0).
The thread 0x1714 has exited with code 0 (0x0).
The thread 0x265c has exited with code 0 (0x0).
The program '[8104] QTAgent32_40.exe' has exited with code 0 (0x0).
The thread 0x2d9c has exited with code 0 (0x0).
The thread 0xde4 has exited with code 0 (0x0).
The thread 0x3bc has exited with code 0 (0x0).
The thread 0x253c has exited with code 0 (0x0).
The program '[12012] testhost.x86.exe: Program Trace' has exited with code 0 (0x0).
The program '[12012] testhost.x86.exe' has exited with code 0 (0x0).
Run Code Online (Sandbox Code Playgroud)

我试过修复Visual Studio并安装最新的比特等无济于事.我在两台不同的机器上遇到了这个问题.

Jac*_*SFT 1

我用的是最新的VS2017 15.5,确实有这个问题:

在此输入图像描述

但在其他VS版本或VS 2017 15.4.4中,确实没有这个问题。

由于我可以重现此问题,因此我可以帮助您在此处向产品团队报告此反馈:

https://developercommunity.visualstudio.com/content/problem/161803/cant-debug-coded-ui-test-in-latest-vs2017.html

如果可能,您可以添加您的评论并对此反馈进行投票。

更新:

我将 VS2017 更新到 15.5.1 版本,然后设置系统环境变量,如下面的屏幕截图所示,注意:您的 VS2017 将安装到 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise 等路径\Common7\IDE。然后我重新启动VS IDE并重新打开测试项目,现在我可以很好地调试它了。

由于VS最新版本为15.5.2,也请更新至最新版本。

在此输入图像描述