开发者

Unit testing C# implementation with F#-based testing tools

Outside of things syntactical, are there scenarios where it would be advantageous to write unit tests using F# for Greenfield C# code?

Here's a scena开发者_Python百科rio:

  1. You're in a team where all developers are C# 2.0-only, slowly learning about LINQ and lambdas.

  2. They don't cover a single line with unit tests, which would place unit tests in F# at rarefied heights.

  3. Unit testing is a choice and responsibility of the developer who is creating code.

  4. If unit tests break, and the dev who wrote them is not on hand, the tests will be simply thrown away if they are hard to understand.

  5. Main requirement here is to create production code in C#.


The fact that unit test snippets can easily be executed in F# Interactive is another possible advantage of testing with F#.

That said, it sounds like for this particular scenario/organization, it might be enough work trying to get anyone to write/execute unit tests, so it may be better to just start with some C# unit tests and focus on getting the 'unit tests are good/useful' culture instilled first.


I have found writing tests in FsUnit ( which is just a wrapper over nunit ) to be great and also the readability is good as well. ( for example you don't have to Pascal the test name. It can be a normal sentence. )

But like Brian says, in your case, you are better off starting with C# for the unit tests and then see how things go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜