Conjecture.FSharp
0.29.0
dotnet add package Conjecture.FSharp --version 0.29.0
NuGet\Install-Package Conjecture.FSharp -Version 0.29.0
<PackageReference Include="Conjecture.FSharp" Version="0.29.0" />
<PackageVersion Include="Conjecture.FSharp" Version="0.29.0" />
<PackageReference Include="Conjecture.FSharp" />
paket add Conjecture.FSharp --version 0.29.0
#r "nuget: Conjecture.FSharp, 0.29.0"
#:package Conjecture.FSharp@0.29.0
#addin nuget:?package=Conjecture.FSharp&version=0.29.0
#tool nuget:?package=Conjecture.FSharp&version=0.29.0
Conjecture.FSharp
Idiomatic F# wrappers around Conjecture property-based testing. Exposes a Gen<'a> strategy type with the usual combinators (map, filter, bind, oneOf, tuple2, list, set, option, result, auto) and a PropertyRunner that turns an 'a -> bool (or 'a -> unit) into a runnable property.
Install
dotnet add package Conjecture.Core
dotnet add package Conjecture.FSharp
To run properties under Expecto, use the Conjecture.FSharp.Expecto integration.
Usage
open Conjecture
open System.Threading.Tasks
let genIntList : Gen<int list> = Gen.list (Gen.int (-100, 100))
let reverseInvolutive (xs: int list) : bool =
List.rev (List.rev xs) = xs
let runResult : Task<PropertyResult> =
PropertyRunner.runBool genIntList reverseInvolutive
match runResult.Result with
| PropertyResult.Passed -> printfn "ok"
| PropertyResult.Failed msg -> failwith msg
For records and discriminated unions, Gen.auto<'a> () derives a generator via FSharp.Reflection:
type Address = { Street: string; ZipCode: int }
type Customer = { Name: string; Address: Address option }
let genCustomer : Gen<Customer> = Gen.auto<Customer> ()
API
| Function | Returns | Notes |
|---|---|---|
Gen.constant v |
Gen<'a> |
Always yields v. |
Gen.int (min, max) / Gen.float (...) / Gen.string (...) / Gen.bool |
Gen<_> |
Primitive generators. |
Gen.list g / Gen.set g / Gen.seq g / Gen.option g / Gen.result ok err / Gen.tuple2 g1 g2 |
composed Gen<_> |
Standard structural generators. |
Gen.map f g / Gen.filter p g / Gen.bind f g / Gen.oneOf gs |
Gen<_> |
Combinators. |
Gen.auto<'a> () |
Gen<'a> |
Reflection-based generator for records and DUs (uses FSharp.Reflection; not trim-safe). |
PropertyRunner.runBool g test |
Task<PropertyResult> |
Runs test : 'a -> bool; false is failure. |
PropertyRunner.runUnit g test |
Task<PropertyResult> |
Runs test : 'a -> unit; any exception is failure. |
PropertyResult.Passed / PropertyResult.Failed of string |
DU | Outcome including a formatted counterexample. |
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Conjecture.Core (>= 0.29.0)
- FSharp.Core (>= 10.1.203)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Conjecture.FSharp:
| Package | Downloads |
|---|---|
|
Conjecture.FSharp.Expecto
Expecto integration for Conjecture.FSharp property-based testing. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.29.0 | 110 | 5/9/2026 |
| 0.28.0 | 106 | 5/9/2026 |
| 0.27.1 | 123 | 4/28/2026 |
| 0.26.0 | 105 | 4/27/2026 |
| 0.25.0 | 114 | 4/27/2026 |
| 0.24.0 | 101 | 4/26/2026 |
| 0.23.0 | 105 | 4/26/2026 |
| 0.22.0 | 100 | 4/26/2026 |
| 0.21.0 | 105 | 4/26/2026 |
| 0.20.0 | 110 | 4/25/2026 |
| 0.19.0 | 108 | 4/25/2026 |
| 0.18.0 | 105 | 4/23/2026 |
| 0.17.0 | 121 | 4/23/2026 |
| 0.16.0 | 106 | 4/22/2026 |
| 0.15.0 | 107 | 4/22/2026 |
| 0.14.0 | 113 | 4/21/2026 |
| 0.13.0 | 111 | 4/19/2026 |
| 0.12.0 | 108 | 4/19/2026 |