Learn R Programming

hedgehog (version 0.2)

Property-Based Testing

Description

Hedgehog will eat all your bugs. 'Hedgehog' is a property-based testing package in the spirit of 'QuickCheck'. With 'Hedgehog', one can test properties of their programs against randomly generated input, providing far superior test coverage compared to unit testing. One of the key benefits of 'Hedgehog' is integrated shrinking of counterexamples, which allows one to quickly find the cause of bugs, given salient examples when incorrect behaviour occurs.

Copy Link

Version

Install

install.packages('hedgehog')

Monthly Downloads

1,350

Version

0.2

License

MIT + file LICENSE

Maintainer

Huw Campbell

Last Published

November 3rd, 2025

Functions in hedgehog (0.2)

tree

Lazy rose trees
symbolic

A symbolic value.
generate

Compose generators
shrink.removes

Produce permutations of removing num elements from a list.
shrink.towards

Shrink an integral number by edging towards a destination.
hedgehog

Property based testing in R
gen.gamma

Generate a float with a gamma distribution
shrink.halves

Shrink a number by dividing it into halves.
shrink.list

Shrink a list by edging towards the empty list.
gen.example

Sample from a generator.
gen.c

Generate a vector of values from a generator
gen.actions

Generate a list of possible actions.
discard

Discard a test case
gen-monad

Generators
gen.beta

Generate a float with a gamma distribution
gen-element

Random Sample Generation
command

State based testing commands
expect_sequential

Execute a state machine model
gen.date

Generate a date between the from and to dates specified.
forall

Hedgehog property test
gen.recursive

Build recursive structures in a way that guarantees termination.
gen.structure

Generate a structure
gen.no.shrink

Stop a generator from shrinking
gen.shrink

Helper to create a generator with a shrink function.
gen.run

Run a generator
gen.sized

Sized generator creation
gen.list

Generate a list of values, with length bounded by the size parameter.
gen.unif

Generate a float between the from and to the values specified.
tree.replicate

Creating trees of lists