Coder Social home page Coder Social logo

fsharp-hedgehog's Introduction

fsharp-hedgehog NuGet Travis

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.

Building from source

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

Linux-specific

If you are using Linux you will also need Mono installed (in order to run Paket). The full install sequence (for Ubuntu) will be something like this.

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

The first time you run it, this will use Paket to restore all the packages, and then build the code.

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

After building the source (for release configuration, i.e. dotnet build -c Release), you can produce the NuGet package with Paket:

.paket/paket.exe pack src/Hedgehog

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

fsharp-hedgehog's People

Contributors

moodmosaic avatar jacobstanley avatar porges avatar frankshearar avatar ploeh avatar

Watchers

James Cloos avatar Herb Martin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.