【问题标题】:VsTest NUnit xml.document error .NET CoreVsTest NUnit xml.document 错误.NET Core
【发布时间】:2018-06-24 08:21:45
【问题描述】:

我在 .NET Core 2.0 项目中创建了 NUnit 测试。我想使用 VsTest - TestAssemblies 将它们作为VSTS 版本的一部分运行。当我在 VSTS 中为我​​的 DLL 运行此步骤时,我收到以下错误(或者更确切地说是警告),并且没有发现任何测试。当我在本地计算机上运行 VsTest.console.exe 时,相同的 DLL 可以工作。

2018-01-15T16:40:03.9599708Z Microsoft (R) Test Execution Command Line Tool Version 15.0.26929.2
2018-01-15T16:40:03.9600907Z Copyright (c) Microsoft Corporation.  All rights reserved.
2018-01-15T16:40:03.9602205Z 
2018-01-15T16:40:03.9861859Z vstest.console.exe 
2018-01-15T16:40:03.9862327Z "d:\a\r1\a\AutomationTest\drop\Tests\bin\Release\netcoreapp2.0\SecureApp.dll"
2018-01-15T16:40:03.9862517Z "d:\a\r1\a\drop\Tests\bin\Release\netcoreapp2.0\SecureApp.dll"
2018-01-15T16:40:03.9862856Z /logger:"trx"
2018-01-15T16:40:03.9862945Z /TestAdapterPath:"d:\a\r1\a"
2018-01-15T16:40:07.8106612Z Starting test execution, please wait...
2018-01-15T16:40:20.0035350Z Warning: Error initializing RunSettings. Default settings will be used
2018-01-15T16:40:20.0035696Z 
2018-01-15T16:40:21.4269527Z Warning: System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.XPath.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2018-01-15T16:40:21.4269844Z File name: 'System.Xml.XPath.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
2018-01-15T16:40:21.4270026Z    at NUnit.VisualStudio.TestAdapter.AdapterSettings.Load(String settingsXml)
2018-01-15T16:40:21.4270199Z    at NUnit.VisualStudio.TestAdapter.AdapterSettings.Load(IDiscoveryContext context) in C:\Users\..\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\AdapterSettings.cs:line 168
2018-01-15T16:40:21.4270463Z    at NUnit.VisualStudio.TestAdapter.NUnitTestAdapter.Initialize(IDiscoveryContext context, IMessageLogger messageLogger) in C:\Users\..\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitTestAdapter.cs:line 122
2018-01-15T16:40:21.4270606Z 
2018-01-15T16:40:21.4270754Z WRN: Assembly binding logging is turned OFF.
2018-01-15T16:40:21.4270915Z To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
2018-01-15T16:40:21.4271067Z Note: There is some performance penalty associated with assembly bind failure logging.
2018-01-15T16:40:21.4271212Z To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
2018-01-15T16:40:21.4272472Z 
2018-01-15T16:40:21.4272556Z 
2018-01-15T16:40:21.4272665Z Information: NUnit Adapter 3.9.0.0: Test execution started
2018-01-15T16:40:21.4272742Z 
2018-01-15T16:40:21.4883313Z Warning: Exception System.IO.FileNotFoundException, Exception thrown executing tests
2018-01-15T16:40:21.4883790Z 
2018-01-15T16:40:21.4884316Z Warning: Could not load file or assembly 'System.Xml.XPath.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2018-01-15T16:40:21.4884557Z 
2018-01-15T16:40:21.4899528Z Warning:    at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, TestFilter filter)
2018-01-15T16:40:21.4900101Z    at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle) in C:\Users\..\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 98
2018-01-15T16:40:21.4900392Z 
2018-01-15T16:40:21.4915162Z Warning: Exception System.IO.FileNotFoundException, Exception thrown executing tests
2018-01-15T16:40:21.4915561Z 
2018-01-15T16:40:21.4915917Z Warning: Could not load file or assembly 'System.Xml.XPath.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2018-01-15T16:40:21.4916177Z 
2018-01-15T16:40:21.4916415Z Warning:    at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, TestFilter filter)
2018-01-15T16:40:21.4916739Z    at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle) in C:\Users\..\source\repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 98
2018-01-15T16:40:21.4916960Z 
2018-01-15T16:40:21.4917196Z Information: NUnit Adapter 3.9.0.0: Test execution complete
2018-01-15T16:40:21.4917380Z 
2018-01-15T16:40:21.6170092Z Warning: No test is available in d:\a\r1\a\AutomationTest-.NET Desktop-CI\drop\Tests\bin\Release\netcoreapp2.0\SecureApp.dll d:\a\r1\a\drop\Tests\bin\Release\netcoreapp2.0\SecureApp.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
2018-01-15T16:40:21.6171012Z 
2018-01-15T16:40:21.7226473Z 
2018-01-15T16:40:22.3665104Z Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
2018-01-15T16:40:22.3665729Z 
2018-01-15T16:40:22.6599654Z ##[warning]No results found to publish.

为什么在我的本地机器上发现了 xmlDocument.dll,但在 VSTS 上却没有发现?

在我的本地文件夹中,我也没有 XmlDocument.dll

【问题讨论】:

  • 您是如何为 .net core 2.0 应用添加 nunit 测试的?您可以在一个驱动器中添加您的项目吗?并且请检查是否在.csproj中本地添加了一些引用。
  • 我使用 nuget 添加了它:Nunit (3.9.0) 和 NUnit3TestAdapter (3.9.0)。 .csproj 中没有此 dll 的引用。此外,我设法让它与 vsts 中的 dotnet 测试任务一起工作,但不能与 vstest 一起工作。问题是,对于 dotnet 测试任务,我无法将 dll 定义为仅 csproj 的输入,这还不够好,因为我正在从其他目录复制构建的工件。你是否知道 vsts 中的 vstest 和 dotnet 测试任务有什么区别?
  • VS 测试任务还应该为 .net 核心应用程序构建 nunit 测试。并且 dotnet test 不需要指定 dll,因为它已经指定了项目。
  • 我遇到了同样的问题。有解决办法吗?

标签: unit-testing nunit azure-devops vstest nunittestadapter


【解决方案1】:

我遇到了同样的问题,最终放弃了“VsTest - TestAssemblies”任务,因为我意识到可以将命令设置为测试的“.NET Core”任务。

在运行 .NET Core 2.0 时,这将根据需要自动运行 NuGet 恢复和构建。所以真正需要运行所有在 .NET Core 项目中编写的测试的唯一任务。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,但是在将System.Xml.XPath.XDocument NuGet 包添加到测试项目后,它就运行了。

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题,但在我安装了System.Xml.XPath.XmlDocument 的最新和稳定版本后,问题就消失了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-07-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-03
        • 2018-05-06
        • 2020-08-22
        • 1970-01-01
        相关资源
        最近更新 更多