使用 xUnit 处理 netstandard1.6 [英] Handle netstandard1.6 with xUnit

查看:22
本文介绍了使用 xUnit 处理 netstandard1.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望为 netstandard1.6 库使用测试框架.我尝试关注和编辑 开始使用 xUnit.net (.NET Core/ASP.NET Core) 没有成功.使用我的 project.json 文件在 VS 2015 Update 3 RTM 上使用 dotnetcore 库按照 xUnit 的教程来重现错误.

I am looking to use a test framework for a netstandard1.6 library. I tried to follow and edit Getting started with xUnit.net (.NET Core / ASP.NET Core) without success. Follow the xUnit's tutorial with a dotnetcore lib on VS 2015 Update 3 RTM with my project.json file to reproduce the error.

project.json :

project.json :

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "xunit": "2.2.0-beta2-build3300",
    "dotnet-test-xunit": "2.2.0-preview2-build1029"
  },
  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

错误:

Severity    Code    Description
Error       NU1002  The dependency dotnet-test-xunit 2.2.0-preview2-build1029 does not support framework .NETStandard,Version=v1.0

我可以降级到 dotnet-test-xunit 2.2.0-preview2-build1029 支持的 .netstandard 版本吗?是否有任何已知的解决方法可以将 xUnit 与它一起使用?

Can I downgrade to a version of .netstandard supported by dotnet-test-xunit 2.2.0-preview2-build1029? Is there any known work around to use xUnit with it?

由于我是一个新的 project.json 和 dotnetcore,我可能会错过一些有用的东西.

As I am a bit new project.json and dotnetcore, I might missed something useful.

推荐答案

这对我有用.似乎现有的 xunit 版本还不支持 netstandard 1.6 库.尝试将您的项目 json 更改为 xunit 站点 中提供的样子.这也假设您创建了一个 .net 核心库项目

This worked for me. It seems existing xunit versions do not support the netstandard 1.6 library yet. Try changing your project json to look like this as provided for in xunit site. This also assumes that you created a .net core library project

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "dependencies": {
    "xunit": "2.2.0-beta2-build3300",
    "dotnet-test-xunit": "2.2.0-preview2-build1029"
  },
  "frameworks": {
    "netcoreapp1.0": {
       "dependencies": {
          "Microsoft.NETCore.App": {
             "type": "platform",
             "version": "1.0.0"
           }
         }
      }
   }
}

这篇关于使用 xUnit 处理 netstandard1.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆