首页 文章

在VSTS中未发现.NET Core 2.0 xUnit测试

提问于
浏览
3

我试图 Build 与.NET Core 2.0项目和xUnit的VSTS持续集成 .

我已经安装了xunit.runner.visualstudio NuGet包,并且在Visual Studio中一切正常 .

VSTS无法找到任何测试 .

到目前为止我能找到的是this article,它描述了如何使用project.json将其设置为.NET Core 1.0 . 不幸的是,它不会工作,因为project.json在.NET Core 2.0中消失了 .

有什么建议?

VSTS输出:

2017-11-08T20:00:30.4824989Z ## [section]开始:VsTest - testAssemblies 2017-11-08T20:00:30.4834988Z =================== ================================================== ========= 2017-11-08T20:00:30.4834988Z任务:Visual Studio Test 2017-11-08T20:00:30.4834988Z描述:使用Visual Studio测试运行器运行测试2017-11-08T20:00 :30.4834988Z版本:2.2.3 2017-11-08T20:00:30.4834988Z作者:微软公司2017-11-08T20:00:30.4834988Z帮助:更多信息2017-11-08T20:00:30.4834988Z ==== ================================================== ======================== 2017-11-08T20:00:31.2064989Z使用vstest.console.exe在本地运行测试2017-11-08T20: 00:31.2064989Z ============================================== ========== 2017-11-08T20:00:31.2074983Z测试选择器:测试组件2017-11-08T20:00:31.2084986Z测试组件:\ release * test * .dll,\ release \ netcoreapp2 .0 单位 .dll, - :\ xunit.runner.visualstudio.testadapter.dll,!\ obj ** 2017-11-08T20:00:31.2084986Z测试fi lter criteria:null 2017-11-08T20:00:31.2094992Z搜索文件夹:d:\ a \ 1 \ s 2017-11-08T20:00:31.2094992Z运行设置文件:d:\ a \ 1 \ s 2017-11 -08T20:00:31.2094992Z并行运行:false 2017-11-08T20:00:31.2115263Z隔离运行:false 2017-11-08T20:00:31.2184982Z自定义适配器的路径:null 2017-11-08T20:00 :31.2194992Z其他控制台选项:null 2017-11-08T20:00:31.2194992Z启用代码覆盖率:false 2017-11-08T20:00:31.2205509Z选择用于测试执行的VisualStudio版本:最新2017-11-08T20:00:32.3430734 Z ================================================= ======= 2017-11-08T20:00:38.4660600Z [command]“C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Enterprise \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow \ vstest . console.exe“@d:\ a_temp \ 7a0ab851-c4bf-11e7-9264-0bc93cd5677b.txt 2017-11-08T20:00:38.6420650Z Microsoft(R)测试执行命令行工具版本15.0.26929.2 2017-11-08T20: 00:38.6420650Z版权所有(c)Microsoft Corporation . 版权所有 . 2017-11-08T20:00:38.6420650Z 2017-11-08T20:00:38.6420650Z vstest.console.exe 2017-11-08T20:00:38.6430604Z“d:\ a \ 1 \ s \ Salgsapp \ MyTestProject.Business .Unit \ bin \ Release \ netcoreapp2.0 \ MyTestProject.Business.Unit.dll“2017-11-08T20:00:38.6430604Z”d:\ a \ 1 \ s \ Salgsapp \ MyTestProject.Business.Unit \ bin \ Release \ netcoreapp2.0 \ xunit.runner.reporters.netcoreapp10.dll“2017-11-08T20:00:38.6430604Z”d:\ a \ 1 \ s \ Salgsapp \ MyTestProject.Business.Unit \ bin \ Release \ netcoreapp2.0 \ xunit.runner.u力.netcoreapp10.dll“2017-11-08T20:00:38.6430604Z”d:\ a \ 1 \ s \ Salgsapp \ MyTestProject.Business.Unit \ bin \ Release \ netcoreapp2.0 \ xunit.runner .visualstudio.dotnetcore.testadapter.dll“2017-11-08T20:00:38.6430604Z / logger:”trx“2017-11-08T20:00:38.6430604Z / TestAdapterPath:”d:\ a \ 1 \ s“2017- 11-08T20:00:39.2010599Z开始测试执行,请稍候...... 2017-11-08T20:00:39.7672139Z警告:d:\ a \ 1 \ s \ Salgsapp \ MyTestProject.Business.Unit中没有测试可用\ bin \ Release \ netcoreapp2.0 \ MyTestProject.Business.Unit.dll d:\ a \ 1 \ s \ Salg sapp \ MyTestProject.Business.Unit \ bin \ Release \ netcoreapp2.0 \ xunit.runner.reporters.netcoreapp10.dll d:\ a \ 1 \ s \ Salgsapp \ MyTestProject.Business.Unit \ bin \ Release \ netcoreapp2.0 \ xunit.runner.utility.netcoreapp10.dll d:\ a \ 1 \ s \ Salgsapp \ MyTestProject.Business.Unit \ bin \ Release \ netcoreapp2.0 \ xunit.runner.visualstudio.dotnetcore.testadapter.dll . 确保已安装的测试发现者和执行者,平台和框架版本设置适当,然后重试 . 2017-11-08T20:00:39.7682139Z 2017-11-08T20:00:39.7812142Z 2017-11-08T20:00:40.6140742Z信息:此外,如果测试发现者和执行者是,则可以尝试指定'/ UseVsixExtensions'命令作为vsix扩展安装在计算机上,您的安装支持vsix扩展 . 示例:vstest.console.exe myTests.dll / UseVsixExtensions:true 2017-11-08T20:00:40.6140742Z 2017-11-08T20:00:43.0551327Z ## [警告]未找到结果发布 . 2017-11-08T20:00:43.0711309Z ## [section]整理:VsTest - testAssemblies

项目定义:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
    <PackageReference Include="Moq">
      <Version>4.7.142</Version>
    </PackageReference>
    <PackageReference Include="MSTest.TestAdapter" Version="1.1.18" />
    <PackageReference Include="MSTest.TestFramework" Version="1.1.18" />
    <PackageReference Include="xunit">
      <Version>2.3.1</Version>
    </PackageReference>
    <PackageReference Include="xunit.runner.visualstudio">
      <Version>2.3.1</Version>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyTestProject.Business\MyTestProject.Business.csproj" />
  </ItemGroup>

</Project>

构建配置:

enter image description here

1 回答

  • 5

    您需要在Visual Studio Test任务中的IED \ Extensions \ TestPlatform文件夹和框架选项中指定vstest.console.exe:

    enter image description here

相关问题