What unit testing frameworks are available for F#

后端 未结 3 463
暗喜
暗喜 2020-11-30 06:26

I am looking specifically for frameworks that allow me to take advantage of unique features of the language. I am aware of FsUnit. Would you recommend something else, and

3条回答
  •  盖世英雄少女心
    2020-11-30 06:50

    You could try my unit testing library Expecto; it's has some features you might like:

    • F# syntax throughout, tests as values; write plain F# to generate tests
    • Use the built-in Expect module, or an external lib like Unquote for assertions
    • Parallel tests by default
    • Test your Hopac code or your Async code; Expecto is async throughout
    • Pluggable logging and metrics via Logary Facade; easily write adapters for build systems, or use the timing mechanism for building an InfluxDB+Grafana dashboard of your tests' execution times
    • Built in support for BenchmarkDotNet
    • Build in support for FsCheck; makes it easy to build tests with generated/random data or building invariant-models of your object's/actor's state space

    Hello world looks like this

    open Expecto
    
    let tests =
      test "A simple test" {
        let subject = "Hello World"
        Expect.equal subject "Hello World" "The strings should equal"
      }
    
    []
    let main args =
      runTestsWithArgs defaultConfig args tests
    

提交回复
热议问题