编码的UI测试现在得到的错误有关Newtonsoft.json未找到 [英] Coded UI Test now gets error about Newtonsoft.json not being found

查看:506
本文介绍了编码的UI测试现在得到的错误有关Newtonsoft.json未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的编码的UI测试登录到一个应用程序。测试是数据驱动的,从TFS使用的数据。我们使用的是TfsTestAgent用户(拥有管理员权限),它是在服务器和代理系统上都。当我执行的测试中,我看到了以下错误:

 单元测试适配器未能连接到数据源或读取数据。 
关于解决此错误的详细信息,请参阅故障排除数据驱动的
单元测试(http://go.microsoft.com/fwlink/?LinkId=62412)在MSDN Library.Error
详细:无法加载文件或程序'Newtonsoft.Json,版本= 4.5.0.0,
区域性=中性公钥= 30ad4fe6b2a6aeed'或它的一个依赖。在
系统找不到指定的文件。



测试运行日志(UITestLog.html)显示这一点:

  I,2524,81,2015年3月24日,13:27:09.815,14494724802,QTAgent32_40.exe,ExtensionFramework:从定制目录扩展阅读'C:\\ \\Program文件(x86)\Common Files\Microsoft Shared\VSTT\12.0\UITestExtensionPackages'
V,2524,81,2015年3月24日,13:27:09.830,.\QTAgent32_40 .EXE,UnitTestExecuter.RunClassInitializeMethod:获取m_runner.SyncRoot。
V,2524,81,2015年3月24日,13:27:09.830,.\QTAgent32_40.exe,UnitTestExecuter.RunClassInitializeMethod:收购m_runner.SyncRoot。
V,2524,81,2015年3月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年3月24日,13:27:09.830,.\QTAgent32_40.exe ,UnitTestExecuter.RunClassInitializeMethod:发布m_runner.SyncRoot。
V,2524,81,2015年3月24日,13:27:09.830,.\QTAgent32_40.exe,UnitTestRunner.ExecuteDataDrivenTest:开始。
V,2524,8,2015年3月24日,13:27:10.377,.\QTAgent32_40.exe,CodedUITest:CodedUITestExtension.BeforeClassCleanup
V,2524,8,2015年3月24日, 13:27:10.377,.\QTAgent32_40.exe,CodedUITest:CodedUITestExtension.AfterClassCleanup
V,2524,8,2015年3月24日,13:27:10.393,.\QTAgent32_40.exe,CodedUITest:CodedUITestExtension .Dispose()
我,2524,8,2015年3月24日,13:27:10.393,.\QTAgent32_40.exe,UnitTestRunner.Dispose。



有趣的是,Newtonsoft.Json(又名Json.Net)未在项目中使用在全部或任何引用的库。从上面的日志,在我看来,这是外界的编码的UI测试,因为它未注册为一个脚本异常。



接下来的问题是,为什么会这样开始改变这种编码的UI系统下运行测试后用户?我曾尝试通过快照恢复回原来的用户(和更改测试管理器主机环境)。这样做使我有同样的结果之上。



我在找什么方法可以进一步这样或想法的调试修复。我曾尝试以下为失败修复:




  • 包括Newtonsoft.Json在溶液

  • 副本在库到c:\Program文件(x86)\Microsoft的Visual Studio 12.0\Common7\IDE\PublicAssemblies

  • 恢复到已知的工作构建并运行它(仍得到同样的错误)
  • 要注意


大的事情是,最后一个项目。我建立,我知道工作,并在多台机器的工作。使用这些基础上的任何机器产生相同的结果。什么会导致该错误信息,并机/测试代码的独立?


解决方案

错误



该错误消息




无法加载文件或程序集Newtonsoft.Json,版本= 4.5.0.0,
文化=中性公钥= 30ad4fe6b2a6aeed'或其依赖项之一。




这里有一点要知道的是,这个错误有两个选项:




  1. 它无法找到 Newtonsoft.Json

  2. 它无法找到一个依赖



分析



分析这类问题的典型方法是使用过程监控[微软的Sysinternals]



如果你想完全手工做,请按照下列步骤操作:




  1. 运行进程监视器

  2. 添加过滤器有问题

  3. 可执行重现问题

  4. <李>停止记录事件一旦问题已被复制
  5. 的艰巨的任务:从底部,查找错误找不到名称找不到路径拒绝访问。你必须找到有问题,不跟成功后,一个DLL(如果DLL搜索路径中后期发现可能发生这种情况)。



我已经自动化这个过程,并提供进程监视器日志分析器的下载。免责声明:我这个免费工具的作者



通过该工具,步骤是:




  1. 运行进程监视器

  2. 添加过滤器有问题

  3. 可执行重现问题

  4. 停止记录事件一旦问题已被复制

  5. 保存进程监视器日志为XML

  6. 在进程监视器日志打开XML分析

  7. 转至虽然项目从上到下



您的问题




接下来的问题是,为什么改变这种编码的UI系统下运行?




也许老字号的用户有足够的访问权限和新的用户则不能。这不应该是一个管理员用户的原因(尽管还是有可能)。



也许老用户在有不同的文件夹路径和新的用户则不能。




有趣的是,Newtonsoft.Json(又名JSON。净)是不是在全部或引用的库项目中使用。




我不知道你怎么检查过。请注意,你不能简单地使用的Dependency Walker 了解.NET。你需要的东西。NET具体,例如 dotPeek [JetBrains公司] ,但dotPeek不显示在一旦所有的依赖,你需要经过手动所有引用。但是,这并不会寻找失踪机DLL。因此,对我来说是最可靠的方法是由上述进程监视器。




可能会导致该错误信息,并机/测试代码的独立是什么?




和以前一样:用户特定的配置


I have a simple Coded UI test to log into an application. The test is data driven and uses data from TFS. We are using a TfsTestAgent user (that has admin privileges) that is on both the server and the agent systems. When I execute the test, I see the following error:

    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.

The test run log (UITestLog.html) shows this:

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.

The interesting thing is that Newtonsoft.Json (aka Json.Net) isn't used in the project at all or any referenced libraries. From the above log, it appears to me that this is outside of the coded UI test since it isn't registered as a script exception.

The question then is, why did this start after changing the user that the Coded UI system runs tests under? I have tried reverting it back to the original user via a snapshot (and change the host environment in Test Manager). Doing so gives me the same result above.

I'm looking for any ways to debug this further or ideas for fixes. I have tried the following as failed fixes:

  • including Newtonsoft.Json in the solution
  • copy over the library to c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies
  • revert to a known working build and run it (still get same error)

Big thing to note is that last item. I had builds that I know worked and worked on multiple machines. Using those builds on any machine produces the same result. What could cause that error message and be machine/test code independent?

解决方案

The error

The error message is

Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.

One thing to know here is that this error has two options:

  1. It cannot find Newtonsoft.Json
  2. It cannot find a dependency

The analysis

The typical way to analyze this sort of problem is using Process Monitor [Microsoft SysInternals].

If you want to do it fully manually, follow these steps:

  1. Run Process Monitor
  2. Add a filter for the executable which has the problem
  3. Reproduce the issue
  4. Stop recording events once the problem has been reproduced
  5. The hard task: From the bottom, look for errors Name not found, Path not found or Access denied. You have to find a DLL that has a problem and is not followed by Success later (which may happen if the DLL is found late in the search paths).

I have automated this process and provide Process Monitor Log Analyzer for download. Disclaimer: I'm the author of this free tool.

With that tool, the steps are:

  1. Run Process Monitor
  2. Add a filter for the executable which has the problem
  3. Reproduce the issue
  4. Stop recording events once the problem has been reproduced
  5. Save Process Monitor log as XML
  6. Open the XML in Process Monitor Log Analyzer
  7. Go though the items from top to bottom

Your questions

The question then is, why did this start after changing the user that the Coded UI system runs tests under?

Maybe the "old" user had sufficient access rights and the "new" user doesn't. This should not be the reason for an admin user (though still possible).

Maybe the "old" user had different folders in the PATH and the "new" user doesn't.

The interesting thing is that Newtonsoft.Json (aka Json.Net) isn't used in the project at all or any referenced libraries.

I wonder how you checked that. Note that you cannot simply use Dependency Walker for .NET. You need something .NET specific, e.g. dotPeek [JetBrains], but dotPeek does not show all dependencies at once, you'd need to go through all references manually. However, this will not find missing native DLLs. Therefore, the most reliable way for me is Process Monitor as described before.

What could cause that error message and be machine/test code independent?

Same as before: user specific configurations.

这篇关于编码的UI测试现在得到的错误有关Newtonsoft.json未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆