Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# NUnit无法加载MSTestAdapter/MSTestFramework DLL和;“找不到任何测试”;_C#_Selenium_Azure Devops_Nunit_Mstest - Fatal编程技术网

C# NUnit无法加载MSTestAdapter/MSTestFramework DLL和;“找不到任何测试”;

C# NUnit无法加载MSTestAdapter/MSTestFramework DLL和;“找不到任何测试”;,c#,selenium,azure-devops,nunit,mstest,C#,Selenium,Azure Devops,Nunit,Mstest,我正在使用NUnit进行单元测试,我想将它集成到azure devops中。 当我使用测试资源管理器在visual Studio中本地运行测试时, 测试能够正常运行而不出现故障 但是,当我在azure devops上构建它时,我遇到了NUnit无法加载MSTestAdapter和MSTestFramework DLL或者找不到MSTestAdapter/MSTestFramework DLL的问题 起初,当我仔细查看时,我认为这是因为我的处理器架构不匹配。因此,我尝试创建一个runsetting

我正在使用NUnit进行单元测试,我想将它集成到azure devops中。 当我使用测试资源管理器在visual Studio中本地运行测试时, 测试能够正常运行而不出现故障

但是,当我在azure devops上构建它时,我遇到了NUnit无法加载MSTestAdapter和MSTestFramework DLL或者找不到MSTestAdapter/MSTestFramework DLL的问题

起初,当我仔细查看时,我认为这是因为我的处理器架构不匹配。因此,我尝试创建一个runsettings文件,并将测试平台更改为x64,以便NUnit与测试匹配。 但是,它仍然不起作用,并给了我相同的错误消息(如下所示)

我尝试过的Runsettings文件中的代码:

    ```` <RunSettings>
     ````<!-- Configurations that affect the Test Framework -->
     ```` <RunConfiguration>
        ````<TargetPlatform>x64</TargetPlatform>
     ````   <TargetFrameWorkVersion>Framework45</TargetFrameWorkVersion>
     ```` </RunConfiguration>
    ```` </RunSettings>


Just a part of the error messages
The error message is what i get at the VSTest part in azure devops when i build my project

(the messages are all similar) :

Multiple versions of same extension found. Selecting the highest version.
  Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter : 14.0.2505.1
Input string was not in a correct format.
Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Unable to load types from the test source 'd:\a\1\s\MSTest.TestAdapter.1.3.2\build\_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll'. Some or all of the tests in this source may not be discovered.
Input string was not in a correct format.
Unable to load types from the test source 'd:\a\1\s\MSTest.TestAdapter.1.3.2\build\uap10.0\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll'. Some or all of the tests in this source may not be discovered.
Input string was not in a correct format.
NUnit Adapter 3.12.0.0: Test execution started
Running all tests in d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
   NUnit failed to load d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
Running all tests in d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
   NUnit couldn't find any tests in d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
Running all tests in d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
   NUnit couldn't find any tests in d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll

`
````
```` 
````x64
````框架45
```` 
```` 
只是错误消息的一部分
错误消息是我在构建项目时在azure devops中的VSTest部分得到的
(这些信息都很相似):
找到同一扩展的多个版本。选择最高版本。
Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter:14.0.2505.1
输入字符串的格式不正确。
无法从程序集“Microsoft.VisualStudio.TestPlatform.TestFramework,版本=14.0.0.0,区域性=中性,PublicKeyToken=b03f5f7f11d50a3a”加载类型“Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope”。
无法从程序集“Microsoft.VisualStudio.TestPlatform.TestFramework,版本=14.0.0.0,区域性=中性,PublicKeyToken=b03f5f7f11d50a3a”加载类型“Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope”。
无法从测试源“d:\a\1\s\MSTest.TestAdapter.1.3.2\build\\u common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll”加载类型。可能找不到此源中的部分或所有测试。
输入字符串的格式不正确。
无法从测试源“d:\a\1\s\MSTest.TestAdapter.1.3.2\build\uap10.0\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll”加载类型。可能找不到此源中的部分或所有测试。
输入字符串的格式不正确。
NUnit适配器3.12.0.0:已开始执行测试
在d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll中运行所有测试
NUnit无法加载d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
在d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll中运行所有测试
NUnit在d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll中找不到任何测试
在d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll中运行所有测试
NUnit在d:\a\1\s\HeyX.UnitTest\bin\Debug\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll中找不到任何测试

NUnit项目的框架版本和visual studio版本是什么

在“visual studio测试”任务中,可以选择visual studio版本

可能NUnit项目的版本高于任务的版本


如果是这种情况,您可以指定vstestconsole的路径。

错误指示“无法从程序集“Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope”加载类型“Microsoft.VisualStudio.TestPlatform.TestFramework,版本=14.0.0…”

“Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope”仅适用于或更高版本。您的测试项目可能引用了错误的程序集

MSTest.TestAdapter.1.3.2包和Microsoft.VisualStudio.TestPlatform.14.0.0包都有Microsoft.VisualStudio.TestPlatform.TestFramework程序集。但只有包MSTest.TestAdapter.1.3.2中的一个具有“Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope”

您可以尝试将“Microsoft.VisualStudio.TestPlatform.TestFramework”引用指向测试csproj文件中MSTest.TestFramework.1.3.2所在的文件夹

在我自己的.net framework测试项目中,我更改了位于标记“reference Microsoft.VisualStudio.TestPlatform.TestFramework…”下的标记“HintPath”的值,如下所示:

<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> 
 <HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
 </Reference>
 <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">        
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
 </Reference>

..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll

显然我的视觉工作室出了问题。不太确定我的vs的哪一部分影响了我的测试,但在重新安装vs并从头开始构建之后,我能够在devops上构建而没有任何错误。

嗨,保罗,我不确定我是否理解,但我相信目标框架版本都设置为net45(?)不确定这是否有助于解决问题:测试运行将使用DLL为framework.NETFramework构建,版本=v4.0,平台为X86。以下DLL与框架/平台设置不匹配。Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.DLL是为框架4.5和平台AnyCPU构建的。Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll是为Framework 4.5和平台AnyCPU构建的。Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll是为Framework 4.5和平台AnyCPU构建的。您在本地说,一切正常,但在azure devops中,一切都是错误的,有您给出的错误!。下面是一个示例的屏幕截图,您可以在其中更改测试任务的VisualStudio版本。我想你是在用这个测试?显然我的视觉工作室出了点问题。不太确定我的vs的哪一部分影响了我的测试,但是在控制之后