Skip to content

moka-rs/moka-props

Repository files navigation

Moka Props

Moka Props is a test tool to perform stateful property-based testing on the Moka cache.

It will randomly generate commands with arguments, run them against the cache implementations and verify the returned values. It is like a superset of QuickCheck, which will not only generate test data, but also generate test cases.

Overview

This tool is still in an early stage of development and missing many test cases. But it will eventually generate commands including the followings:

  • Create a cache with various configurations.
  • Insert an entry with controlled-random key and value.
  • Get an existing or not-existing entry.
  • Invalidate an existing or not-existing entry.
  • Tick cache's internal expiration clock.
  • Pause or resume cache's internal bookkeeping tasks.
  • Swap write log entries in the internal queue to emulate race conditions in concurrent writes.
  • Drop a cache.

This tool uses the following frameworks/libraries and programming languages:

  • PropEr, a property-based testing framework written in Erlang programming language.
  • PropCheck, an Elixir binding for PropEr.
  • Elixir programming language, for writing properties.
  • Rustler, a library for writing Erlang Native Implemented Functions (NIFs) in safe Rust code.
  • Rust programming language, for creating a dynamic-link library containing Moka and its wrapper functions.

Why property-based testing?

Property-based testing helps us create better, more solid tests with little code. It will complement unit test based testing.

Prerequisites

You need a machine running macOS or Linux.

You also need to install the following tools before building this tool:

Testing the properties (Running tests)

Clone this repository:

$ git clone https://github.com/moka-rs/moka-props.git
$ cd moka-props

Get the dependencies for Elixir:

$ mix deps.get

Build and run the tests:

$ mix test

Developing properties

To learn about PropEr, we would recommend the following book:

License

TODO: Write this section and add the license file(s).

  • Moka Props itself might be distributed under either of the MIT license or the Apache-2.0 license.
  • Be aware that PropEr and PropCheck are distributed under the GPL-3.0 license.
    • You might want to run Moka Props, which links to PropEr and PropCheck, only in your development and testing environment.
    • You might want to avoid linking your final product to PropEr and PropCheck.

About

Stateful property-based testing for Moka cache

Resources

Stars

Watchers

Forks