私は、.netコアで動作するF#ユニットテストプロジェクトを作成しようとしています。.netコアでF#プロジェクトの単体テストを行う方法はありますか?
dotnet new -t xunittest
は、C#用のxunitテストプロジェクトを作成しますが、F#にはそのような同等のプロジェクトは存在しません。
上記のC# "dotnet new"から出力されるproject.jsonとテストファイルを修正し、F#で動作させるために必要なビットを追加しようとしました。それはうまくいかなかった。 "dotnet test"とタイプしてテストをビルドし、さらに "実行"しますが、テストは必ずしも実行しないでください。
セットアップで何か不足していますか、F#テストプロジェクトを作成するために追求できる別の(おそらく全く異なる)オプションがありますか?再び、私は特に.netコアで動作させることに重点を置いています。
project.json
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"compilerName": "fsc",
"compile": {
"includeFiles": [
"Tests.fs"
]
}
},
"dependencies": {
"System.Runtime.Serialization.Primitives": "4.3.0",
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-*"
},
"tools": {
"dotnet-compile-fsc": "1.0.0-preview2.1-*"
},
"testRunner": "xunit",
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629"
},
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
}
}
Tests.fs
module Tests
open Xunit
[<Fact>]
let ``Should Fail`` =
Assert.False true
出力DOTNETテスト
xUnit.net .NET CLI test runner (64-bit .NET Core win10-x64)
Discovering: FSTests
Discovered: FSTests
=== TEST EXECUTION SUMMARY ===
FSTests.dll Total: 0
SUMMARY: Total: 1 targets, Passed: 1, Failed: 0.