我安装了FsUnit
» nuget install fsunit
Attempting to resolve dependency 'NUnit (≥ 2.6.3)'.
Installing 'NUnit 2.6.3'.
Successfully installed 'NUnit 2.6.3'.
Installing 'FsUnit 1.3.0.1'.
Successfully installed 'FsUnit 1.3.0.1'.我创建了简单的单元测试:
module Tests
open NUnit.Framework
open FsUnit
[<Test>]
let ``simple test`` () =
1 |> should equal 1下面是我正在进行的测试:
» fsharpc -r NUnit.2.6.3/lib/nunit.framework.dll -r FsUnit.1.3.0.1/Lib/Net40/FsUnit.NUnit.dll 01_binomial_tests.fs
F# Compiler for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
/Users/demas/development/book_exericses/fsharp_deep_dive/01_binomial_tests.fs(7,1): warning FS0988: Main module of program is empty: nothing will happen when it is run它编译得很好,但我不知道如何在没有VS的情况下启动测试
更新
我试过使用NUnit.Runners
> nuget install NUnit.Runners
> fsharpc -r NUnit.2.6.3/lib/nunit.framework.dll -r FsUnit.1.3.0.1/Lib/Net40/FsUnit.NUnit.dll --target:library 01_binomial_tests.fs
> mono NUnit.Runners.2.6.4/tools/nunit-console.exe 01_binomial_tests.dll
NUnit-Console version 2.6.4.14350
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Unix 14.4.0.0
CLR Version: 2.0.50727.1433 ( Mono 3.5 ( 3.10.0 ((detached/92c4884 Thu Nov 13 23:27:38 EST 2014) ) )
ProcessModel: Default DomainUsage: Single
Execution Runtime: mono-3.5
Could not load file or assembly '01_binomial_tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.发布于 2015-06-09 15:16:32
你有几个选择:
NUnit.Runners NuGet包的依赖,该包附带独立运行程序。我个人使用假,因为它很好地自动化了一切。要做到这一点,您需要在您的假build.fsx脚本中添加这样的内容:
Target "Test" (fun _ ->
!! "/tests*.dll |> NUnit (fun p ->
{p with
DisableShadowCopy = true;
OutputFile = testDir + "TestResults.xml" })
)您将需要对FAKE和NUnit.Runners的依赖关系,然后FAKE也会自动找到运行程序(因此您不必在构建脚本中显式地设置它)。
https://stackoverflow.com/questions/30736006
复制相似问题