Skip to content

Release with confidence, state-of-the-art property testing for .NET.

License

Notifications You must be signed in to change notification settings

TysonMN/fsharp-hedgehog

 
 

Repository files navigation

fsharp-hedgehog NuGet

Hedgehog will eat all your bugs.

Hedgehog is a modern property-based testing system, in the spirit of QuickCheck. Hedgehog uses integrated shrinking, so shrinks obey the invariants of generated values by construction.

Features

  • Integrated shrinking, shrinks obey invariants by construction.
  • Convenient syntax for generators and properties with gen and property expressions.
  • Range combinators for full control over the scope of generated numbers and collections.

Example

The root namespace, Hedgehog, includes almost everything you need to get started writing property tests with Hedgehog.

open Hedgehog

Once you have your import declaration set up, you can write a simple property:

let propReverse : Property<Unit> =
    property {
        let! xs = Gen.list (Range.linear 0 100) Gen.alpha
        return xs |> List.rev |> List.rev = xs
        }

You can then load the module in F# Interactive, and run it:

> Property.print propReverse
+++ OK, passed 100 tests.

More examples can be found in the tutorial.

👉 For auto-generators (à la AutoFixture) and other convenience generators, check out fsharp-hedgehog-experimental.

Building from source

To build Hedgehog from source, you will need either the .NET Core SDK or Visual Studio.

Building & running tests

With Visual Studio you can build Hedgehog and run the tests from inside the IDE, otherwise with the dotnet command-line tool you can execute:

dotnet build

To run the tests, you can execute:

dotnet test tests/Hedgehog.Tests/Hedgehog.Tests.fsproj
dotnet test tests/Hedgehog.CSharp.Tests/Hedgehog.CSharp.Tests.csproj

Building the NuGet package

dotnet pack src/Hedgehog/Hedgehog.fsproj -c Release

This will produce Hedgehog-x.y.z.nupkg in src/Hedgehog/bin/Release.

About

Release with confidence, state-of-the-art property testing for .NET.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • F# 95.0%
  • C# 4.7%
  • Shell 0.3%