O'Reilly logo

Testing with F# by Mikael Lundin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

FsUnit

The current state of unit testing in F# is good. You can get all the major test frameworks running with little effort, but there is still something that feels a bit off with the way tests and asserts are expressed:

open NUnit.Framework
Assert.That(result, Is.EqualTo(42))

Using FsUnit, you can achieve much higher expressiveness in writing unit tests by simply reversing the way the assert is written:

open FsUnit
result |> should equal 42

Please refer to Chapter 3, Setting Up Your Test Environment, on how to set up a testing environment with FsUnit.

The FsUnit framework is not a test runner in itself, but uses an underlying test framework to execute. The underlying framework can be of MSTest, NUnit, or xUnit. FsUnit can best be explained as having ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required