elm-explorations / test

Write unit and fuzz tests for Elm code.
https://package.elm-lang.org/packages/elm-explorations/test/latest
BSD 3-Clause "New" or "Revised" License
236 stars 40 forks source link

Fuzzer classification and coverage #187

Closed Janiczek closed 1 year ago

Janiczek commented 2 years ago

Fixes #94




Fuzz.labelExamples

Screenshot 2022-07-29 at 22 38 57

Test.reportCoverage

Screenshot 2022-07-29 at 21 19 13

Test.expectCoverage

zero

Screenshot 2022-08-20 at 17 25 12

more than zero

Screenshot 2022-08-20 at 17 25 36

at least

Screenshot 2022-08-20 at 17 24 44
Janiczek commented 2 years ago

@gampleman raises a good question in #94 about using Expect.classify or Expect.cover (modulo names) instead of having this in FuzzOptions (thus living in Test). Still unsure about it. I'll first implement the statistical test for reducing flakiness which we need no matter where this lives 🙃

mpizenberg commented 2 years ago

I'm not well versed on this subject and can't check it before mid next week. So if you feel confident about one way of doing it, I won't be against. If you prefer waiting for a more detailed answer from me, I'll need some time.

On Sat, Sep 10, 2022, 18:54 Simon Lydell @.***> wrote:

@.**** commented on this pull request.

In src/Test/Coverage/Internal.elm https://github.com/elm-explorations/test/pull/187#discussion_r967677090:

+{-| Coverage checks will be allowed to give a false positive once in certainty

+runs (that is, with probability 1/certainty).

+

+The current number was taken from Haskell QuickCheck. Their documentation says

+(quote):

+

+> If you are using 'checkCoverage' as part of a test suite, you should

+> be careful not to set @certainty@ too low. If you want, say, a 1% chance

+> of a false positive during a project's lifetime, then @certainty@ should

+> be set to at least @100 * m * n@, where @m@ is the number of uses of

+> 'cover' in the test suite, and @n@ is the number of times you expect the

+> test suite to be run during the project's lifetime. The default value

+> is chosen to be big enough for most projects.

+

+In the future we might want to make it configurable, as it is a knob to make

+tests finish faster at the expense of larger probability of false positives.

I have honestly not followed this closely enough so I don’t really know. But we already do some regex on the JS so adding some more for this if needed sounds good to me!

— Reply to this email directly, view it on GitHub https://github.com/elm-explorations/test/pull/187#discussion_r967677090, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWFOCPDC5AZUB4QRJ2VBVLV5S4NVANCNFSM54YWLBCQ . You are receiving this because you were mentioned.Message ID: @.***>

Janiczek commented 1 year ago

Pulling the plug on this as we're nearing the release! There's still a week or so left, please shout if you find an issue or have a question or there is something to reconsider.