The sad state of property-based testing libraries

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. hedgehog

    Release with confidence, state-of-the-art property testing for Haskell.

    when realizing that those numbers don't come easily. [3]

    [1]: https://hackage.haskell.org/package/hedgehog-1.4/docs/src/He...

    [2]: https://gee.cs.oswego.edu/dl/papers/oopsla14.pdf

    [3]: https://github.com/hedgehogqa/haskell-hedgehog/issues/191

    Wonder why most property-testing libaries don't have features like this?

    The libraries require training to use. And they're not that easy to write.

    > the current state-of-the-art when it comes to property-based testing is stateful testing via a state machine model and reusing the same sequential state machine model combined with linearisability to achieve parallel testing

    Okay, okay. I admit I've never performed property-based stateful testing, nor in parallel. So that may be the coolest feature out there, because it addresses one of the hardest problems in testing.

    But I think that yet other things have happened with modern property-testing libraries (e.g. Hypothesis, PropEr, Hedgehog, Validity):

    Shrinking for free [4], generators for free [5], defining the probability distribution of your sub-generators in a composable way.

    Maybe those features are not as significant, but they're equally missing from almost all property-test libaries.

    [4]: Gens N’ Roses: Appetite for Reduction • Jacob Stanley • YOW! 2017 https://www.youtube.com/watch?v=LfD0DHqpeVQ

    [5]: https://tech.fpcomplete.com/blog/quickcheck-hedgehog-validit...

  2. InfluxDB

    InfluxDB – Built for High-Performance Time Series Workloads. InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.

    InfluxDB logo
  3. coyote

    Coyote is a library and tool for testing concurrent C# code and deterministically reproducing bugs.

    I believe Java has exactly that, but I couldn't recall the project name.

    In the case of .NET, there is https://github.com/microsoft/coyote which works by rewriting IL to inject hooks that control concurrent execution state.

    It would have been much more expensive to have a custom interpreter specifically for this task (CoreCLR never interprets IL, it compiles it immediately to unoptimized machine code for fast startup, and then recompiles it one or multiple times as the method gets executed more and as JIT gathers its execution profile for PGO-driven compilation).

    This approach somewhat reminds me of precise release-mode debugging and tracing framework for C++ a friend of mine was talking about, which relies on either manually adding the hooks to source files or doing so automatically with a tool.

  4. CsCheck

    Random testing library for C#

    For my C#/.NET testing I've been using CsCheck[0] and I've enjoyed it quite a bit. It was a lot more approachable compared to Hedgehog and FsCheck and is also quite fast.

    [0] https://github.com/AnthonyLloyd/CsCheck

  5. buf-list

    A list of Rust buffers that implements the bytes::Buf trait.

    I write stateful property tests with Rust's proptest quite regularly, I just tend to handcode it which is quite straightforward. See https://github.com/sunshowers-code/buf-list/blob/main/src/cu... for a nontrivial example which found 6 bugs.

  6. shuttle

    Shuttle is a library for testing concurrent Rust code (by awslabs)

    i.e. top level true randomness, then a bunch of nested loops (only 2 here, but some tests have more) to go from low-complexity cases to high-complexity

    then generate a seed to seed a deterministic PRNG, and print it out so if the test fails, I just copy and paste the error seed to replay the error case

    I have found doing this manual proptesting to be faster, more flexible, and generally less fuss than using any frameworks or libraries

    That said, for really robust concurrency testing, I cannot recommend enough the AWS Shuttle library (https://github.com/awslabs/shuttle) which can find insanely complicated race conditions. I wrote a little tutorial on it here: https://grantslatton.com/shuttle

    We used it at AWS to verify the custom filesystem we wrote to power AWS S3.

  7. aa

    Immutable AA Trees (by ncruces)

    With the advent of coverage based fuzzing, and how well supported it is in Go, what am I missing from not using one of the property based testing libraries?

    https://www.tedinski.com/2018/12/11/fuzzing-and-property-tes...

    Like with the below fuzz test, and the corresponding invariant checks, is that equivalent to a property test?

    https://github.com/ncruces/aa/blob/505cbbf94973042cc7af4d6be...

    https://github.com/ncruces/aa/blob/505cbbf94973042cc7af4d6be...

  8. libprotobuf-mutator

    Library for structured fuzzing with protobuffers

    [3]: https://github.com/google/libprotobuf-mutator

  9. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  10. noblit

    An immutable append-only database

  11. fsharp-hedgehog

    Release with confidence, state-of-the-art property testing for .NET.

    Haha yeah I kinda went off the deep end with applicatives. Here's a short primer on applicative vs monadic shrinking behavior using F# syntax https://github.com/hedgehogqa/fsharp-hedgehog/issues/419#iss...

    You can think of `let!` as `let + await`, and `let! x ... and! y` as `await Parallel([x, y])`.

    Please feel free to ask any questions if it's still confusing!

  12. VisualFSharp

    The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio

    Not quite accurate with the Parallel example. Don Syme is explicit that applicative `async` should not implicitly start work in the thread pool (https://github.com/dotnet/fsharp/issues/10301#issuecomment-7...).

  13. arbtest

    A minimalist property-based testing library

    Do you have a model problem which is tricky to shrink?

    I implemented a stupid simple shrinker for arbitrary, and I’d love to know a specific example where it fails to shrink in a good way:

    https://github.com/matklad/arbtest/blob/0191f93846e9f7e38254...

    I know at lest two interesting approaches for making that way smarter, but I don’t yet have a problem where my dumb approach isn’t sufficient.

  14. hypothesis

    The property-based testing library for Python

    Anecdotally, I had a fantastic experience with `clojure.spec.alpha` (with or without `test.check`), and when I went to use python's `hypothesis` it was just... abysmal.

    It seems like Hypothesis is unable to handle simple but "large" data sets >>by design<<, where "large" is really not so large. [0] It was such a pain that we ripped out Hypothesis (and generative testing altogether, sadly) completely from our python test suite at work.

    [0] https://github.com/HypothesisWorks/hypothesis/issues/3493

  15. fuzzcheck-rs

    Modular, structure-aware, and feedback-driven fuzzing engine for Rust functions

    Agreed. A while back I played around with fuzzcheck [1], which let's you write coverage-guided, structure-aware property tests, but the generation is smarter than just slamming a fuzzer's `&[u8]` input into `Arbitrary`. It also supports shrinking, which is nice. Don't know that I would recommend it though. It seemed difficult to write your own `Mutator`s. It also looks somewhat unmaintained nowadays, but I think the direction is worth exploring.

    [1]: https://github.com/loiclec/fuzzcheck-rs/

  16. sanitizers

    AddressSanitizer, ThreadSanitizer, MemorySanitizer

  17. test.contract

    quickcheck of stateful protocols

    Clojure does have stateful quickcheck library now: https://github.com/griffinbank/test.contract

    Parallel testing is interesting, but hasn't been a large source of pain yet.

  18. osv

    Discontinued Open source vulnerability DB and triage service. [Moved to: https://github.com/google/osv.dev] (by google)

    TLA+, Formal Methods in Python: FizzBee, Nagini, Deal-solver, Dafny: https://news.ycombinator.com/item?id=39938759 :

    > Python is Turing complete, but does [TLA,] need to be? Is there an in-Python syntax that can be expanded in place by tooling for pretty diffs; How much overlap between existing runtime check DbC decorators and these modeling primitives and feature extraction transforms should there be? (In order to: minimize cognitive overload for human review; sufficiently describe the domains, ranges, complexity costs, inconstant timings, and the necessary and also the possible outcomes given concurrency,)

    From "S2n-TLS – A C99 implementation of the TLS/SSL protocol" https://news.ycombinator.com/item?id=38510025 :

    > But formal methods (and TLA+ for distributed computation) don't eliminate side channels. [in CPUs e.g. with branch prediction, GPUs, TPUs/NPUs, Hypervisors, OS schedulers, IPC,]

    Still though, coverage-based fuzzing;

    From https://news.ycombinator.com/item?id=30786239 :

    > OSS-Fuzz runs CloudFuzz[Lite?] for many open source repos and feeds OSV OpenSSF Vulnerability Format: https://github.com/google/osv#current-data-sources

    From "Automated Unit Test Improvement using Large Language Models at Meta"

  19. awesome-python-testing

    Collection of awesome 😎️ Python resources for testing

  20. paranoid_crypto

    Paranoid's library contains implementations of checks for well known weaknesses on cryptographic artifacts.

  21. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts