简体   繁体   English

如何在Visual Studio 2015中测试F#?

[英]How do I test F# in Visual Studio 2015?

I need a sane solution to test my f# code. 我需要一个理智的解决方案来测试我的f#代码。 I think that unqote is really nice library, and i guess that fuchu is helpful to group the test. 我认为unqote是非常好的库,我想fuchu有助于分组测试。

namespace Frank
module MyTest =
  open Fuchu 
  open Swensen.Unquote
  [<Tests>]
  let t = 
    testCase "1" <| fun _ ->  
      test <@ 1 + 1  = 3 @>

It works fine from fsi 它从fsi工作正常

#load "Scripts/load-references-debug.fsx"
open Fuchu
#load "regexTest.fs"
open Frank.MyTest
run t

or as a console application as described in https://github.com/mausch/Fuchu 或者作为https://github.com/mausch/Fuchu中描述的控制台应用程序

open Fuchu
[<EntryPoint>]
let main args = defaultMainThisAssembly args

with the wonderful output 精彩的输出

1: Failed: 

1 + 1 = 3
2 = 3
false

1 tests run: 0 passed, 0 ignored, 1 failed, 0 errored (00:00:00.0024090)

But i believe also in visual Studio is a mechanism to Discover and run specific tess, which has the Test Exporer window and the Test\\run\\All Tests menue entry. 但我相信Visual Studio也是一种发现和运行特定Test Exporer的机制,它具有Test Exporer窗口和Test\\run\\All Tests菜单条目。

Unfortunately this is not working for me, as Visal Studio 2015 does not discover those tests 不幸的是,这对我不起作用,因为Visal Studio 2015没有发现这些测试

------ Discover test started ------
========== Discover test finished: 0 found (0:00:00.0220136) ==========

I have seen this working, even on my machine. 我已经看到这个工作,甚至在我的机器上。 But now I didn't. 但现在我没有。 I like to get this orking, by understanding how the test discovery works in VS2015. 通过了解测试发现在VS2015中的工作原理,我喜欢这个orking。

Could you make MyTest.t a function? 你能让MyTest.t成为一个功能吗?

[<Test>]
let t () =
   // ...

Right now it is defined as a property and I don't think NUnit will see this as a test. 现在它被定义为属性,我不认为NUnit会将此视为测试。

I've written a Visual Studio test adapter for Fuchu. 我为Fuchu编写了一个Visual Studio测试适配器。 The source is at https://github.com/interactsw/fuchu-adapter and it's available from github as the Fuchu.Adapter package. 源代码位于https://github.com/interactsw/fuchu-adapter ,它可以从github获得,作为Fuchu.Adapter包。 This enables Fuchu tests to show up in Visual Studio's Test Explorer window. 这使得Fuchu测试能够显示在Visual Studio的“ 测试资源管理器”窗口中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM