All Projects → hedgehogqa → Fsharp Hedgehog

hedgehogqa / Fsharp Hedgehog

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

Programming Languages

csharp
926 projects
fsharp
127 projects

Projects that are alternatives of or similar to Fsharp Hedgehog

Haskell Hedgehog
Release with confidence, state-of-the-art property testing for Haskell.
Stars: ✭ 584 (+166.67%)
Mutual labels:  test, testing-tools, property-based-testing, quickcheck
Swiftcheck
QuickCheck for Swift
Stars: ✭ 1,319 (+502.28%)
Mutual labels:  property-based-testing, quickcheck
Snapper
Bringing Jest-esque Snapshot testing to C#
Stars: ✭ 85 (-61.19%)
Mutual labels:  test, testing-tools
Prig
Prig is a lightweight framework for test indirections in .NET Framework.
Stars: ✭ 106 (-51.6%)
Mutual labels:  test, testing-tools
Rapid
Rapid is a Go library for property-based testing that supports state machine ("stateful" or "model-based") testing and fully automatic test case minimization ("shrinking")
Stars: ✭ 213 (-2.74%)
Mutual labels:  property-based-testing, quickcheck
Assert
A collection of convenient assertions for Swift testing
Stars: ✭ 69 (-68.49%)
Mutual labels:  test, testing-tools
Qcheck
QuickCheck inspired property-based testing for OCaml.
Stars: ✭ 194 (-11.42%)
Mutual labels:  property-based-testing, quickcheck
Cypress
Fast, easy and reliable testing for anything that runs in a browser.
Stars: ✭ 35,145 (+15947.95%)
Mutual labels:  test, testing-tools
Nsubstitute
A friendly substitute for .NET mocking libraries.
Stars: ✭ 1,646 (+651.6%)
Mutual labels:  test, testing-tools
Swagger meqa
Auto generate and run tests using swagger/OpenAPI spec, no coding needed
Stars: ✭ 151 (-31.05%)
Mutual labels:  test, testing-tools
Fast Check
Property based testing framework for JavaScript (like QuickCheck) written in TypeScript
Stars: ✭ 2,604 (+1089.04%)
Mutual labels:  property-based-testing, quickcheck
Qcstm
A simple state-machine framework for OCaml based on QCheck
Stars: ✭ 50 (-77.17%)
Mutual labels:  property-based-testing, quickcheck
Quick check.js
A JS implementation of quick_check
Stars: ✭ 48 (-78.08%)
Mutual labels:  property-based-testing, quickcheck
Testcafe
A Node.js tool to automate end-to-end web testing.
Stars: ✭ 9,176 (+4089.95%)
Mutual labels:  test, testing-tools
Mts
Project of Multi-protocol Test Tool opensourced by Ericsson
Stars: ✭ 34 (-84.47%)
Mutual labels:  test, testing-tools
Kotlinfixture
Fixtures for Kotlin providing generated values for unit testing
Stars: ✭ 94 (-57.08%)
Mutual labels:  test, testing-tools
Hitchhiker
a Restful Api test tool
Stars: ✭ 2,175 (+893.15%)
Mutual labels:  test, testing-tools
Faker
Faker is a pure Elixir library for generating fake data.
Stars: ✭ 673 (+207.31%)
Mutual labels:  test, testing-tools
Junit Quickcheck
Property-based testing, JUnit-style
Stars: ✭ 821 (+274.89%)
Mutual labels:  property-based-testing, quickcheck
Gest
👨‍💻 A sensible GraphQL testing tool - test your GraphQL schema locally and in the cloud
Stars: ✭ 109 (-50.23%)
Mutual labels:  test, testing-tools

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.render propReverse |> printfn "%s"
+++ 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.

C#/LINQ Example

Hedgehog provides an alternative namespace, meant to provide compatibility with other .NET languages. To use this, simply import the Hedgehog.Linq namespace. The base Hedgehog namespace isn't necessary in this scenario.

Generators are then built with a more comfortable fluent API.

using Hegehog.Linq;

class Generators
{
    static void Example()
    {
        // This creates a generator for 10 character strings, with only alphabetical characters.
        var stringLength = 10;
        var stringGen = Gen.String(Gen.Alpha, Range.FromValue(stringLength));

        // This creates a property that can be checked, rechecked or rendered.
        var property =
            from string in Property.ForAll(stringGen)
            select Assert.AreEqual(stringLength, string.Length);

        // Checking accepts an argument for the number of test cases to generate and check.
        property.Check(tests: 30);
    }
}

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.Linq.Tests/Hedgehog.Linq.Tests.csproj

Building the NuGet package

As of https://github.com/hedgehogqa/fsharp-hedgehog/pull/253/ a NuGet package is created automatically during build.

If you want to manually create a NuGet package you can run:

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

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

Development Environments

Visual Studio

Hedgehog can be developed in Visual Studio, once these requirements are met:

  • .NET Core (2.1+) and .NET Framework (4.5.1+) are installed.

Visual Studio Code

Hedgehog can be developed in Visual Studio Code, with a couple of scenarios supported.

Bare Metal

Developing on bare metal is essentially the same as developing in Visual Studio, install the appropriate .NET SDK then open the project folder.

Remote Containers

Development can also be done using Remote Development.

The steps to get this up and running are as follows:

  1. Install Docker.
  2. Install the Remote Containers extension.
  3. Open the project folder, then run the Remote-Containers: Reopen in Container command.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].