[英]How to create a unit test with F# (using MSTest)
I am trying to learn F# via TDD. 我正在尝试通过TDD学习F#。
However, I am struggling to write my first test: 但是,我正在努力编写我的第一个测试:
module MSTest
open Microsoft.VisualStudio.TestTools.UnitTesting
[<TestClass>] type CalculatorShould () =
[<TestMethod>] member this.''add 1 and 2 with result of 3'' () = Assert.AreEqual(3, 1 + 2)
Any ideas on how to do this? 有关如何执行此操作的任何想法?
I receive the following errors: 我收到以下错误:
Error A type definition requires one or more members or other declarations. 错误类型定义需要一个或多个成员或其他声明。 If you intend to define an empty class, struct or interface, then use 'type ... = class end', 'interface end' or 'struct end'. 如果您打算定义一个空的类,结构或接口,请使用'type ... = class end','interface end'或'struct end'。
Error Unexpected quote symbol in member definition. 错误成员定义中出现意外的引号。 Expected identifier, '(', '(*)' or other token. 预期的标识符“(”,“(*)”或其他标记。
Error 'get' and/or 'set' required c:\\Users\\Bizmonger\\Documents\\Visual Studio 2015\\Projects\\FSharpModel\\Tests_MyTest.fs 5 Error This is not a valid numeric literal. 错误'获取'和/或'设置'必需c:\\ Users \\ Bizmonger \\ Documents \\ Visual Studio 2015 \\ Projects \\ FSharpModel \\ Tests_MyTest.fs 5错误这不是有效的数字文字。 Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s, 4us, 4y, 4uy, 4.0, 4.0f, 4I. 样本格式包括4,0x4,0b0100,4L,4UL,4u,4s,4us,4y,4uy,4.0,4.0f,4I。
I was using the wrong set of characters. 我使用了错误的字符集。
I had to replace 我不得不更换
'' “”
with 同
`` ``
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.