Is there QuickCheck-like testing framework variant for Mathematica?

We could analyse function argument patterns and generating arbitrary values matching patterns. The idea of generating values, testing rewriting rules and validating that the result match the required pattern seem very natural to pattern rewriting system.

  • 2
    $\begingroup$ Take a look at VerificationTest and TestReportObject and TestReport. You will have to do some of the work yourself when compared with some other testing frameworks, but there is a lot of capability there. $\endgroup$ May 21 '20 at 20:19
  • $\begingroup$ thanks @MikeColacino I'm aware of MUnit, but the whole idea of QuickCheck is an automatic test case generation (from types in languages like Haskel or Scala) and property-based testing. In case of Wolfram language we could use automatic generation of test data from patterns. $\endgroup$ May 22 '20 at 8:22
  • $\begingroup$ Hi @PavelPerikov! I just published this, hope it helps! community.wolfram.com/groups/-/m/t/2309649 $\endgroup$
    – Cabral
    Jul 11 at 3:07

I've created a pretty cool package for automated property-based testing called quickcheck.wl, you pass three arguments to the function: the name of you property, the actual property (must be an equation, inequation or anything that yields a boolean value like a logical operator) and some assumptions.

  "Conjugating a complex flips the imaginary sign",
  Conjugate[a] == Re[b] + -1 Im[b] I,
  "Assume" -> {a -> \[CapitalTau]ComplexInteger}

enter image description here

It will test the property by fuzzing the property symbolically. You can specify many types, currently, there are 18 types..

enter image description here

The function can have a few useful options, such as the exponent range of decimals and integers, and minimum-maximum sizes for lists and strings.

enter image description here

  • $\begingroup$ Wow, that's cool! I will give it a try. Thank you! $\endgroup$ Jul 12 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.