【发布时间】:2015-03-25 04:54:30
【问题描述】:
我有一个简单的编码 UI 测试来登录应用程序。该测试是数据驱动的,并使用来自 TFS 的数据。我们正在使用服务器和代理系统上的 TfsTestAgent 用户(具有管理员权限)。当我执行测试时,我看到以下错误:
The unit test adapter failed to connect to the data source or to read the data.
For more information on troubleshooting this error, see "Troubleshooting Data-Driven
Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.Error
details: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0,
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The
system cannot find the file specified.
测试运行日志 (UITestLog.html) 显示如下:
I, 2524, 81, 2015/03/24, 13:27:09.815, 14494724802, QTAgent32_40.exe, ExtensionFramework : Reading extensions from custom dir 'C:\Program Files (x86)\Common Files\Microsoft Shared\VSTT\12.0\UITestExtensionPackages'
V, 2524, 81, 2015/03/24, 13:27:09.830, .\QTAgent32_40.exe, UnitTestExecuter.RunClassInitializeMethod: Acquiring m_runner.SyncRoot.
V, 2524, 81, 2015/03/24, 13:27:09.830, .\QTAgent32_40.exe, UnitTestExecuter.RunClassInitializeMethod: Acquired m_runner.SyncRoot.
V, 2524, 81, 2015/03/24, 13:27:09.830, .\QTAgent32_40.exe, CodedUITest : CodedUITestExtension.BeforeClassInitialize()
V, 2524, 81, 2015/03/24, 13:27:09.830, .\QTAgent32_40.exe, CodedUITest : CodedUITestExtension.AfterClassInitialize()
V, 2524, 81, 2015/03/24, 13:27:09.830, .\QTAgent32_40.exe, UnitTestExecuter.RunClassInitializeMethod: Released m_runner.SyncRoot.
V, 2524, 81, 2015/03/24, 13:27:09.830, .\QTAgent32_40.exe, UnitTestRunner.ExecuteDataDrivenTest: started.
V, 2524, 8, 2015/03/24, 13:27:10.377, .\QTAgent32_40.exe, CodedUITest : CodedUITestExtension.BeforeClassCleanup
V, 2524, 8, 2015/03/24, 13:27:10.377, .\QTAgent32_40.exe, CodedUITest : CodedUITestExtension.AfterClassCleanup
V, 2524, 8, 2015/03/24, 13:27:10.393, .\QTAgent32_40.exe, CodedUITest : CodedUITestExtension.Dispose()
I, 2524, 8, 2015/03/24, 13:27:10.393, .\QTAgent32_40.exe, UnitTestRunner.Dispose.
有趣的是 Newtonsoft.Json(又名 Json.Net)根本没有在项目中使用,也没有在任何引用的库中使用。从上面的日志中,在我看来,这超出了编码的 UI 测试,因为它没有注册为脚本异常。
那么问题来了,为什么这会在更改 Coded UI 系统运行测试的用户之后开始?我尝试通过快照将其还原回原始用户(并更改测试管理器中的主机环境)。这样做会给我上面相同的结果。
我正在寻找进一步调试此问题的任何方法或修复的想法。我尝试了以下失败的修复:
- 在解决方案中包含 Newtonsoft.Json
- 将库复制到 c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies
- 恢复到已知的工作版本并运行它(仍然出现相同的错误)
要注意的是最后一项。我有我知道在多台机器上工作和工作的构建。在任何机器上使用这些构建都会产生相同的结果。什么可能导致该错误消息并且与机器/测试代码无关?
【问题讨论】:
-
.NET 框架现在依赖于 Newtonsoft.Json,尤其是 System.Net.Http。您正在使用 Web API 项目吗?你的 NuGet 依赖项是什么?您可能会遇到 NuGet 包/依赖项版本的问题,您需要将其合并为一个重定向,如此处所示; stackoverflow.com/questions/22685530/…
-
尝试确保机器上也安装了最新的 .NET Framework。
-
我们开始在数据驱动测试中看到此错误,其中参数来自共享步骤。还没找到解决办法。
-
相反,数据驱动的测试使用的是“共享参数”。
标签: c# debugging json.net coded-ui-tests