Skip to content

Commit

Permalink
Allow quietOnSuccess and maxRejected fscheck config
Browse files Browse the repository at this point in the history
  • Loading branch information
rynoV committed Dec 17, 2024
1 parent d597b10 commit f21ca22
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Expecto.FsCheck/FsCheck.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ module ExpectoFsCheck =
let test (config: FsCheckConfig) =
let config =
{ MaxTest = config.maxTest
MaxFail = 1000
MaxFail = config.maxRejected
// We're converting uint64s to a smaller type, but it shouldn't be an issue because users are only using the
// values given in the test output, which are only ints when running FsCheck 2
Replay = Option.map Random.StdGen (config.replay |> Option.map (fun (seed, gamma) -> int seed, int gamma))
Name = name
StartSize = config.startSize
EndSize = config.endSize
QuietOnSuccess = true
QuietOnSuccess = config.quietOnSuccess
Every = fun _ _ -> String.Empty
EveryShrink = fun _ -> String.Empty
Arbitrary = config.arbitrary
Expand Down
3 changes: 2 additions & 1 deletion Expecto.FsCheck3/FsCheck3.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ module ExpectoFsCheck =
.WithName(name)
.WithStartSize(config.startSize)
.WithEndSize(config.endSize)
.WithQuietOnSuccess(true)
.WithQuietOnSuccess(config.quietOnSuccess)
.WithArbitrary(config.arbitrary)
.WithRunner(runner config)
.WithMaxRejected(config.maxRejected)


Check.One(config, property)
Expand Down
10 changes: 8 additions & 2 deletions Expecto/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type SourceLocation =
static member empty = { sourcePath = ""; lineNumber = 0 }

type FsCheckConfig =
/// The maximum number of tests that are run.
{ maxTest: int
{ /// The maximum number of tests that are run.
maxTest: int
/// The size to use for the first test.
startSize: int
/// The size to use for the last test, when all the tests are passing. The size increases linearly between Start- and EndSize.
Expand All @@ -36,6 +36,10 @@ type FsCheckConfig =
finishedTest: FsCheckConfig
-> (* test name *) string
-> Async<unit>
/// If set, suppresses the output from the test if the test is successful.
quietOnSuccess: bool
/// The maximum number of tests where values are rejected, e.g. as the result of ==>
maxRejected: int
}

static member defaultConfig =
Expand All @@ -47,6 +51,8 @@ type FsCheckConfig =
receivedArgs = fun _ _ _ _ -> async.Return ()
successfulShrink = fun _ _ _ -> async.Return ()
finishedTest = fun _ _ -> async.Return ()
quietOnSuccess = true
maxRejected = 1000
}

/// Actual test function; either an async one, or a synchronous one.
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,14 +718,14 @@ like the following.

```fsharp
type FsCheckConfig =
/// The maximum number of tests that are run.
{ maxTest: int
{ /// The maximum number of tests that are run.
maxTest: int
/// The size to use for the first test.
startSize: int
/// The size to use for the last test, when all the tests are passing. The size increases linearly between Start- and EndSize.
endSize: int
/// If set, the seed to use to start testing. Allows reproduction of previous runs.
replay: (uint64 * uint64) option
replay: (uint64 * uint64 * int) option
/// The Arbitrary instances on this class will be merged in back to front order, i.e. instances for the same generated type at the front
/// of the list will override those at the back. The instances on Arb.Default are always known, and are at the back (so they can always be
/// overridden)
Expand All @@ -745,6 +745,10 @@ type FsCheckConfig =
finishedTest: FsCheckConfig
-> (* test name *) string
-> Async<unit>
/// If set, suppresses the output from the test if the test is successful.
quietOnSuccess: bool
/// The maximum number of tests where values are rejected, e.g. as the result of ==>
maxRejected: int
}
```

Expand Down
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 11.0.0-alpha4 - 2024-12-16
* Allow quietOnSuccess and maxRejected fscheck config

### 11.0.0-alpha3 - 2024-10-13
* Add testParamAsync and testParamTask (#512), thanks @1eyewonder

Expand Down

0 comments on commit f21ca22

Please sign in to comment.