Skip to content

Commit

Permalink
Don't remember a failed shirnk as a last test step.
Browse files Browse the repository at this point in the history
Otherwise exceptions get lost.
  • Loading branch information
kurtschelfthout committed Sep 8, 2021
1 parent f52f46c commit 52127b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/FsCheck/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ module Runner =
config.Runner.OnShrink(result.Arguments, config.EveryShrink)
!totalShrinkNb < maxTotalShrinkNb
| Shrink _ ->
lastStep := step
totalShrinkNb := !totalShrinkNb + 1
!totalShrinkNb < maxTotalShrinkNb
| Stop ->
Expand Down Expand Up @@ -641,7 +640,7 @@ type Config with
member __.OnFinished(name,testResult) =
match testResult with
| TestResult.Passed _ -> printf "%s" (onFinishedToString name testResult)
| _ -> failwithf "%s" (onFinishedToString name testResult)
| _ -> failwithf "%s" (onFinishedToString name testResult)

}

Expand Down
11 changes: 10 additions & 1 deletion tests/FsCheck.Test/Runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,16 @@ module RunnerInternals =
.WithParallelRunConfig(Some { MaxDegreeOfParallelism = Environment.ProcessorCount })
.WithArbitrary([typeof<NonNullStringArb>])

Check.One(config, prop)
Check.One(config, prop)

[<Fact>]
let ```QuickThrowOnFailure should surface exception message``() =
try
Check.QuickThrowOnFailure(fun i -> if abs i < 20 then true else failwith "bespoke error message")
do failwith "should have thrown an exception!"
with e ->
Helpers.assertTrue <| e.Message.Contains "with exception:"
Helpers.assertTrue <| e.Message.Contains "bespoke error message"

module Runner =
open RunnerHelper
Expand Down

0 comments on commit 52127b5

Please sign in to comment.