简体   繁体   English

在F#中使用MSTest

[英]Using MSTest with F#

Is it possible to use MSTest with F# in VS2010. 是否可以在VS2010中使用带F#的MSTest。 People has asked this question many times. 人们多次提出这个问题。 But I can't seem to find a solution among the answers. 但我似乎无法在答案中找到解决方案。 Has anybody been able to use MSTest for F# unit testing or should I stick to NUnit? 有没有人能够使用MSTest进行F#单元测试,还是应该坚持使用NUnit?

Yes, you can use MsTest with F# in VS2010. 是的,您可以在VS2010中使用带有F#的MsTest。 At the most basic level, using the [<TestClass>], [<TestMethod>] and related attributes will allow you to run tests from the command line using mstest (in a VS command prompt window). 在最基本的级别,使用[<TestClass>],[<TestMethod>]和相关属性将允许您使用mstest(在VS命令提示符窗口中)从命令行运行测试。 In addition, if you use the trick described here: http://www.atrevido.net/blog/2010/05/07/F+Unit+Testing+With+Visual+Studio+2010.aspx , you will be able to use about 95% of the VS2010 support for unit tests. 此外,如果你使用这里描述的技巧: http//www.atrevido.net/blog/2010/05/07/F+Unit+Testing+With+Visual+Studio+2010.aspx ,你将能够使用大约95%的VS2010支持进行单元测试。

In particular, you can use the Test List Editor, run tests from VS2010 in normal or debug mode, and view test results within VS2010. 特别是,您可以使用测试列表编辑器,在正常模式或调试模式下从VS2010运行测试,并在VS2010中查看测试结果。

If supported by your VS2010 edition, code coverage will also work for F# unit tests. 如果您的VS2010版本支持,代码覆盖率也适用于F#单元测试。

One feature that doesn't work is navigating to the source of a unit test by double-clicking on the test from the test result viewer. 一个不起作用的功能是通过双击测试结果查看器中的测试来导航到单元测试的源。

I've also been able to combine MSTest and FsCheck tests. 我也能够结合MSTest和FsCheck测试。

I think you should stick to NUnit. 我认为你应该坚持使用NUnit。 Have a look here: http://connect.microsoft.com/VisualStudio/feedback/details/564586/make-using-mstest-more-accessible-to-f-projects . 看看这里: http//connect.microsoft.com/VisualStudio/feedback/details/564586/make-using-mstest-more-accessible-to-f-projects There is no progress with that issue. 这个问题没有进展。

A more up to date answer (unless still constrained to vs2010) would include 更新的答案(除非仍限于vs2010)将包括

I've got Unquote working with MsTest via Daniel Mohl's mstest template 我通过Daniel Mohlmstest模板Unquote与MsTest 合作

Although I have no idea if any or all of these would work against vs 2010 虽然我不知道这些中的任何一个或全部是否会对抗2010年

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

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