问题描述
我完全被这个问题所困扰.所以我的团队在服务测试项目中有一个单元测试项目.测试是在测试资源管理器窗格中发现的,但是当我尝试运行测试时,会出现以下错误:
I am completely stuck on this issue. So my team has a unit test project in a services test project. The tests are discovered in the test explorer pane however when I try and run the tests I get these errors:
'具有相同uri的多个测试适配器'executor://xunit/VsTestRunner2' 被发现.忽略适配器'Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner'.请卸载冲突的适配器以避免此警告'
'Multiple test adapters with the same uri 'executor://xunit/VsTestRunner2' were found. Ignoring adapter 'Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner'. Please uninstall the conflicting adapter(s) to avoid this warning'
'[xUnit.net 00:00:00.0251250] 跳过:(找不到依赖程序集 'Microsoft.Extensions.DependencyModel,版本=1.1.0')'
'[xUnit.net 00:00:00.0251250] Skipping: (could not find dependent assembly 'Microsoft.Extensions.DependencyModel, Version=1.1.0')'
'C: 中没有可用的测试.确保测试发现者执行人注册和平台&框架版本设置正确,然后重试.'
'No test is available in C:. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.'
上下文信息:
- Xunit 2.2.0
- Visual Studio 15.5.2
- Windows 10 1709 内部版本:16299.125
我的测试项目 project.json:
My Test Projects project.json:
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.1.3",
"Microsoft.DiaSymReader": "1.0.8",
"Microsoft.DiaSymReader.Native": "1.4.1",
"Microsoft.Extensions.Logging.Abstractions": "1.1.2",
"Microsoft.Extensions.Testing.Abstractions": "1.0.0-preview2-003121",
"Newtonsoft.Json": "9.0.1",
"WebServices": "1.0.0-*",
"xunit": "2.2.0",
"xunit.abstractions": "2.0.1",
"xunit.assert": "2.2.0",
"xunit.core": "2.2.0",
"xunit.extensibility.core": "2.2.0",
"xunit.extensibility.execution": "2.2.0",
"xunit.runner.utility": "2.2.0"
},
"frameworks": {
"net461": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
}
}
奇怪的是它对我的团队成员有用.但不是我.我们环境的不同之处在于:来自 Windows 和 Visual Studio 的最新更新,而它们落后一两个更新.
The Weird thing is that it works for my team members. But not me. The differences in our environments are: the latest update from Windows and Visual Studio, while they are an update or two behind.
有人知道解决方法吗?
推荐答案
我遇到了同样的问题,我通过将 Visual Studio 2017 从 15.5.2 更新到 15.5.4 并从以下位置更新我的测试项目引用来修复它:
I had the same problem and I fixed it by updating Visual Studio 2017 from 15.5.2 to 15.5.4 and updating my test project references from:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
到:
<ItemGroup>
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>
并重新启动 Visual Studio(显然 VS 缓存并使用以前的版本,即使您已经更新).
And restarting Visual Studio (apparently VS caches and uses the previous version even after you've updated).
不确定这三件事中的一件或它们的组合是否修复了它.
Not sure if one of the 3 things or the combination of them fixed it.
这篇关于Xunit 单元测试不会运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!