首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Linux/Mac上启动FsUnit测试

如何在Linux/Mac上启动FsUnit测试
EN

Stack Overflow用户
提问于 2015-06-09 15:09:57
回答 1查看 383关注 0票数 3

我安装了FsUnit

代码语言:javascript
复制
» 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'.

我创建了简单的单元测试:

代码语言:javascript
复制
module Tests

open NUnit.Framework
open FsUnit

[<Test>]
let ``simple test`` () =
  1 |> should equal 1

下面是我正在进行的测试:

代码语言:javascript
复制
» 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

代码语言:javascript
复制
> 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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-09 15:16:32

你有几个选择:

  • 添加对NUnit.Runners NuGet包的依赖,该包附带独立运行程序。
  • 使用Xamarin,它似乎有用于运行测试的单元测试面板
  • 使用假的,这是一个很好的F#构建工具,可以运行单元测试。

我个人使用假,因为它很好地自动化了一切。要做到这一点,您需要在您的假build.fsx脚本中添加这样的内容:

代码语言:javascript
复制
Target "Test" (fun _ ->
    !! "/tests*.dll |> NUnit (fun p ->
        {p with
           DisableShadowCopy = true;
           OutputFile = testDir + "TestResults.xml" })
)

您将需要对FAKENUnit.Runners的依赖关系,然后FAKE也会自动找到运行程序(因此您不必在构建脚本中显式地设置它)。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30736006

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档