如何安装FSharp.xUnit?

时间:2019-03-05 14:41:52

标签: f# xunit

我已经安装了Visual Studio 2017,并包括了测试包和F#包。我正在尝试使用xUnit运行一个简单的测试,但显示未找到xUnit。

module HelloWorldTest

open FsUnit.xUnit
open Xunit

open System.Diagnostics

[<Fact>]
let ``Say Hello`` () =
    Assert.True(true)

错误

The namespace or module 'FsUnit' is not defined.

我尝试使用dotnet安装软件包,但这会产生错误。

> dotnet add package FSharp.xUnit 
  Writing C:\Temp\tmp8DAB.tmp
info : Adding PackageReference for package 'FSharp.xUnit' into project  'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
log  : Restoring packages for C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj
...
error: Unable to find package FSharp.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package FsUnit.xUnit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package xunit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package xunit.runner.visualstudio. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package FSharp.xUnit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package Microsoft.NET.Test.Sdk with version (>= 16.0.0)
error:   - Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 15.9.0]
error: Package 'FSharp.xUnit' is incompatible with 'all' frameworks in project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.

那么我该如何为F#安装xUnit?不幸的是,MS的本指南缺少任何此信息。 https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-fsharp-with-dotnet-test

编辑:

添加NuGet程序包源之后

> dotnet add package FsUnit.xUnit
  Writing C:\Temp\tmp5BA6.tmp
info : Adding PackageReference for package 'FsUnit.xUnit' into project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
log  : Restoring packages for C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj
...
info :   CACHE https://api.nuget.org/v3-flatcontainer/fsunit.xunit/index.json
info : Package 'FsUnit.xUnit' is compatible with all the specified frameworks in project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
info : PackageReference for package 'FsUnit.xUnit' version '3.4.0' updated in file 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.

0 个答案:

没有答案