Property based testing in Lua, inspired by the original QuickCheck.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lqc
rockspecs
spec
.gitignore
.luacov
.travis.yml
CONTRIBUTING.md
LICENSE
Makefile
README.md

README.md

Lua-QuickCheck

Build Status Coverage Status License (MIT)

Lua 5.1 status Lua 5.2 status LuaJIT 2.0 status LuaJIT 2.1 status

Lua-QuickCheck is a Quickcheck clone for Lua.

QuickCheck is a way to do property based testing using randomly generated input. Lua-QuickCheck comes with the ability to randomly generate and shrink integers, doubles, booleans, strings, tables, ...

All QuickCheck needs is a property function -- it will then randomly generate inputs to that function and call the property for each set of inputs. If the property fails (whether by an error or not satisfying your property), the inputs are "shrunk" to find a smaller counter-example.

In short: "Don't write tests... generate them!" - John Hughes

Examples

Some example properties can be found here.

Contributing

For more information on how to contribute to Lua-QuickCheck, take a look at CONTRIBUTING.md.

Installation

From the commandline, enter the following command:

luarocks install lua-quickcheck

After installation, 'lqc' will be available for usage. The lqc command can be configured with various options (use lqc --help for a list of commandline parameters).

Tests

Right now lua-quickcheck uses busted for testing (which calls into the quickcheck engine). Tests can be run with the following command in the root directory of this project:

make tests

Dependencies

  • LuaFilesystem
  • argparse
  • Lua(JIT) FFI (optional, for testing C / C++ / ...)
  • Moonscript (optional, for testing properties written in Moonscript)

Why another QuickCheck clone?

I wanted a quickcheck library that could also easily interface with C or C++ side-by-side with my Lua code.