package hedgehog

  1. Overview
  2. Docs
Property-based testing with integrated shrinking for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

hedgehog-0.1.tbz
sha256=336e7547dd1e41b3e4839a11aaec56d4e2fe14b7dc82a9caa560dbd24f2614f7
sha512=5f040fc5e41b4571b75c460622becd98c54a1d5cb36574a9d2ed6d06e71a5b31673b8ea69d9bb5972af9c71dff58fba2b9d33932a6bffc04c6dcd757583895cb

Description

Hedgehog is a property-based testing library with integrated shrinking, using OCaml 5 effects for assertions and logging.

Added to opam-repository:

README

Hedgehog

Property-based testing with integrated shrinking for OCaml.

Hedgehog is a property-based testing library in the spirit of Haskell Hedgehog. It provides:

  • Integrated shrinking — generators produce a rose tree of outcomes, so every generator shrinks for free. No manual shrink functions needed.
  • Range-controlled generation — numeric ranges separate the concept of bounds from the origin, giving you precise control over value distribution and shrink direction.
  • Algebraic effects for assertions — test bodies use OCaml 5 effects for assert_, annotate, cover, and more, keeping generator and test logic cleanly separated.
  • State machine testing — the Hedgehog.Stm module lets you test stateful systems against abstract models, with sequential and parallel linearizability checking.

Quick example

  open Hedgehog

  let () =
    Property.check
      Property.(property Gen.(
        let* xs = list (Range.linear 0 100) (int (Range.linear 0 1000)) in
        return (fun () ->
          assert_ (List.rev (List.rev xs) = xs))))
    |> ignore

Guides

API reference

Dependencies (3)

  1. domainslib >= "0.5"
  2. ocaml >= "5.1"
  3. dune >= "3.2"

Dev Dependencies (3)

  1. mdx with-test
  2. odoc >= "3.2.1" & with-doc
  3. ocamlformat = "0.29.0" & with-dev-setup

Conflicts

None