【问题标题】:XUnit tests no longer discovered in .Net Core 2.Net Core 2 中不再发现 XUnit 测试
【发布时间】:2017-08-31 07:51:46
【问题描述】:

在将项目从 .Net Core 1.1 移动到 .Net Core 2 之后,我注意到我的 xUnit 测试不再在 VS 2017 中被发现......

任何想法如何让他们回来? :)

更新

经过一些更深入的研究,我发现我的问题与我的测试项目中的这个错误有关:“无法加载文件或程序集 'System.Runtime, Version=4.1.1.0”

更多细节在这里: https://developercommunity.visualstudio.com/content/problem/95070/could-not-load-file-or-assembly-systemruntime-vers.html

【问题讨论】:

  • 什么样的发现?安慰? VS?
  • 对比。编辑描述
  • 包含测试用例的项目是什么样的?如果是 .NET Framework 4.5.x,升级到 4.6.1 及以上。
  • 不,我将我的测试项目从 NetCore 1.1/NetStandard 1.6 移到了 NetCore 2/NetStandard 2。也将 Microsoft 相关软件包更新到了​​版本 2。在那之后 xUnit 测试(现在也在 NetCore 2 项目中)尿布
  • 可以提供csproj吗?

标签: .net-core xunit


【解决方案1】:

我遇到了完全相同的问题,在敲了几个小时后,我发现 .Net Core 2 中的 xunit 要求您的目标框架必须是 netcoreapp2.0 而不是 netstandard2.0。

CS 项目示例:

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

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

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
    <PackageReference Include="xunit" Version="2.2.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
  </ItemGroup>

</Project>

【讨论】:

  • 我遇到了类似的问题,结果我的 csproj 中有 xunit.runner.console 而不是 xunit.runner.visualstudio。感谢您的样品,这就是我强调的问题。
猜你喜欢
  • 2017-04-25
  • 2018-04-21
  • 2018-02-20
  • 1970-01-01
  • 2018-05-16
  • 1970-01-01
  • 2019-08-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多