Skip to content

A very minimal implementation of the core idea of Hypothesis

License

Notifications You must be signed in to change notification settings

DRMacIver/minithesis

Repository files navigation

Minithesis

This is is an incredibly minimal implementation of the core idea of Hypothesis. It is mostly intended to provide a minimal implementation of a powerful modern property-based testing library that is easy to port to new languages.

Minithesis supports the following features absent from most property-based testing libraries.:

  • Generating arbitrary values inline in the test, including based on previous test results
  • Fully generic shrinking
  • A test database
  • Targeted Property-Based Testing

It achieves all of this in less than 500 lines of relatively straightforward Python (plus comments).

Notes

  • The algorithms for both shrinking and targeting are a bit naive but they're not terrible - they should be good enough that using them is better than not having them.
  • The database uses Python's DBM module for simplicity.
  • This is probably best read after or in tandem with our paper about test-case reduction in Hypothesis
  • This does not necessarily track the core Hypothesis implementation that closely and is more an "in spirit" implementation.
  • This probably doesn't work all that well - it's tolerably well tested, but nobody has ever used it for real and probably nobody ever will because why would they when Hypothesis exists?
  • Pull requests to improve clarity extremely welcome. It probably won't ever grow many features (I might implement the database at some point) though because you're not supposed to use it in anger.
  • I've used the (sadly defunct) Hypothesis-for-Ruby naming conventions because those are better than the Python ones because I actually put some thought into them.
  • There is a fairly minimal generator library just to get you started but it's nothing resembling comprehensive and is unlikely to ever be.

Minithesis Ports

There are a number of ports of minithesis (:tada:). The following are the ones I'm aware of:

If you write a port, please submit a pull request to add it to the list!

About

A very minimal implementation of the core idea of Hypothesis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published