FsUnit is a testing/specification framework for F#. It's written entirely in F# and it offers an approach to unit-testing that is an alternative to popular imperative frameworks.
This release adds some new features and it updates the framework to F# 1.9.6.0.
FsUnit allows you to verify your code with statements like this:
1 |> should equal 1
1 |> should not' (equal 2)
["item"] |> should contain "item"
personList |> should have 4 "people"
(fun () -> failwith "BOOM!") |> should (raise'<FailureException>)
null |> should be Null
anObj |> should be (SameAs(otherObj))A complete example in FsUnit might look like this:
#light
#r "FsUnit.dll"
open FsUnit
type LightBulb(state) =
member x.On = state
override x.ToString() =
match x.On with
| true -> "On"
| false -> "Off"
let onSpecs =
let lb = LightBulb(true)
specs "On Specs" [
spec "On should be true."
(lb.On |> should be True)
spec "String representation should equal \"On\"."
(lb.ToString() |> should equal "On")
]
let offSpecs =
let lb = LightBulb(false)
specs "Off Specs" [
spec "Off should be false."
(lb.On |> should be False)
spec "String representation should equal \"Off\"."
(lb.ToString() |> should equal "Off")
]
printfn "%s" (Results.summary())
// 4 passed.
// 0 failed.
// 0 erred.You can find out much more on the project's
home page or on my
blog.
I would love to get your suggestions on how to improve this project!