hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

[ANN] FsUnit 0.6.0

Last post 11-14-2008, 11:37 by toyvo. 1 replies.
Sort Posts: Previous Next
  •  09-04-2008, 7:04 6881

    [ANN] FsUnit 0.6.0

    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!
  •  11-14-2008, 11:37 7735 in reply to 6881

    Re: [ANN] FsUnit 0.6.0

    Hi RayV,

    Does FsUnit include any random testing functionality? I come to F# from Haskell an there's this lovely QuickCheck library (and a port to F# called FsCheck) that does randomized testing. Ideally you throw it a function from 'a to bool, and it picks 100 random 'a-s to test it.. This is how it is in Hakell; FsCheck right now nees some more annotations but the idea is the same.

    Anything like this in FsUnit?


    Cheers,

    --Anton

    --Anton
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems