Home

FsCheck

FsCheck is a property-based testing framework for the .NET platform, inspired by Haskell's QuickCheck. It automatically generates random test data and checks that specified properties hold for many inputs, rather than testing a single example. The approach helps reveal edge cases and incorrect assumptions by exploring a broad space of inputs.

Core concepts include generators (Gen<'T>) for producing values, Arbitrary<'T> definitions that supply both a generator and

FsCheck can be used from F#, C#, and other .NET languages. It integrates with common test frameworks

Features include automatic shrinking, configurable random seeds for reproducibility, sized generation to control data complexity, and

FsCheck is open source under the MIT license and maintained on GitHub. The core library is complemented

a
shrinker,
and
properties
(Prop)
that
describe
invariants
to
verify.
When
a
property
fails,
FsCheck
uses
shrinking
to
try
to
simplify
the
counterexample
to
the
smallest
input
that
still
fails,
making
debugging
easier.
Properties
can
be
written
in
a
declarative
style
and
composed
from
simpler
components
to
model
complex
behavior.
through
adapters
such
as
FsCheck.Xunit,
FsCheck.NUnit,
and
FsCheck.MSTest,
enabling
tests
to
be
discovered
by
standard
runners.
In
F#,
properties
are
typically
written
with
Prop.forAll
and
composed
generators;
in
C#,
tests
can
be
decorated
with
[Property]
or
invoked
via
Check.
The
library
supports
custom
and
composite
generators,
function
values,
and
recursive
data
types,
with
control
over
data
size
and
randomness.
support
for
user-defined
types
through
Arbitrary
instances.
It
provides
a
family
of
combinators
for
building
complex
data
generators
and
properties,
along
with
tooling
to
integrate
into
existing
test
suites
and
continuous
integration
workflows.
by
adapters
for
popular
test
frameworks
and
by
examples
and
guides
to
help
developers
adopt
property-based
testing
in
.NET
projects.