question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot reproduce test results

See original GitHub issue

I’m using FsCheck 2.9 and FsCheck.Xunit 2.9 to test a monadic wrapper around Result type. The complete code is below for inspection. In the last year or so, I’ve seen the test below fail twice (out of thousands of runs on team’s dev machines and build servers) and only once we were able to save the error message containing the seed for value generation. If I use the seed to replay the failing test, the test replay always passes.

This is the full code as used in our codebase:

(* the custom Result type, just a regular DU, not a struct *)
type Result<'result, 'message> =
    | Ok of 'result
    | Error of 'message

(* bind implementation *)
let inline bind (f: 'a -> Result<'b, 'c>) (result: Result<'a, 'c>) =
    match result with
    | Ok x -> f x
    | Error e -> Error e

(* bind infix *)
let inline (>>=) r f = bind f r

(* test aliases since FsCheck doesn't support open generic types *)
type OkType = int
type ErrorType = string

(* the test itself *)
[<Property>]
let associativity
    (f: OkType -> Result<OkType, ErrorType>)
    (g: OkType -> Result<OkType, ErrorType>)
    (result: Result<OkType, ErrorType>) =

    (result >>= f) >>= g = (result >>= (fun v -> (f v) >>= g))

As I said, this test works literally 99.9% of times. The one case where I was able to obtain the full error message is this:

Result Message:
FsCheck.Xunit.PropertyFailedException : Falsifiable, after 47 tests (0 shrinks) (StdGen (242196637,296351952)): Original: (fun:Invoke@3253, fun:Invoke@3253, Ok -12)

But when I tried to run the test manually with the specified StdGen, I wasn’t able to reproduce the failed result. This is what I tried

Check.One({ Config.QuickThrowOnFailure with Replay = Some <| Random.StdGen (242196637,296351952) }, associativity)

I also tried moving the MaxTest and EndSize values from the default of 100 to 10000 and running it few dozen times, but still nothing.

Weirdly enough, there is another property that failed once, also using bind, but it’s part of the result builder tests, so it would be a bit more code to provide here…

Am I doing something wrong when replaying the check? What could possibly be failing there? Is there something wrong with how I’m defining the property in the first place? Or is it a bug in FsCheck’s value generation somehow?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kurtschelfthoutcommented, Sep 29, 2017

Oh, right, thanks. I think FsCheck dep should basically be pinned to = instead of >=. Not sure where the incompatibility comes from though in 2.10 - I updated NUnit, but didn’t touch anything in FsCheck.Xunit.

Anyway don’t see any particular advantage to keeping the >= either, so will change to = .

1reaction
kurtschelfthoutcommented, Sep 24, 2017

I’ve released 2.10.1 which contains a thread-safe function generator, cherry-picked from fscheck3 branch.

Feel free to re-open if that doesn’t help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What should I do if I cannot reproduce experimental ...
Try to replicate the experimental conditions as much as possible, try to get any "hidden" steps if there are any, and if the...
Read more >
What Happens When Someone Fails to Reproduce My ...
When you are conducting research under the pressure to “publish or perish,” the likelihood that your findings will not be reproducible at ...
Read more >
How to Reproduce a Non-Reproducible Defect and Make ...
If the bug is not reproducible, then the testing effort used in finding, analyzing and reporting that particular bug/defect is a total waste....
Read more >
“Closed — Cannot Reproduce” is misleading; Use “ ...
It's more accurate. “Cannot Reproduce” isn't really true; the fact is that you did not reproduce the issue in the time allotted to...
Read more >
Replication crisis
The replication crisis is an ongoing methodological crisis in which the results of many scientific studies are difficult or impossible to reproduce. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found