All Projects → flyingmutant → Rapid

flyingmutant / Rapid

Licence: mpl-2.0
Rapid is a Go library for property-based testing that supports state machine ("stateful" or "model-based") testing and fully automatic test case minimization ("shrinking")

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Rapid

Jqf
JQF + Zest: Coverage-guided semantic fuzzing for Java.
Stars: ✭ 340 (+59.62%)
Mutual labels:  fuzzing, property-based-testing, quickcheck
Fast Check
Property based testing framework for JavaScript (like QuickCheck) written in TypeScript
Stars: ✭ 2,604 (+1122.54%)
Mutual labels:  fuzzing, property-based-testing, quickcheck
fuzz-rest-api
Derive property based testing fast-check into a fuzzer for REST APIs
Stars: ✭ 38 (-82.16%)
Mutual labels:  quickcheck, property-based-testing, fuzzing
swagger-conformance
Python based tool for testing whether your API conforms to its Swagger schema
Stars: ✭ 51 (-76.06%)
Mutual labels:  property-based-testing, fuzzing
Quickcheck State Machine
Test monadic programs using state machine based models
Stars: ✭ 192 (-9.86%)
Mutual labels:  property-based-testing, quickcheck
edd
Erlang Declarative Debugger
Stars: ✭ 20 (-90.61%)
Mutual labels:  quickcheck, property-based-testing
ava-fast-check
Property based testing for AVA based on fast-check
Stars: ✭ 44 (-79.34%)
Mutual labels:  quickcheck, property-based-testing
Haskell Hedgehog
Release with confidence, state-of-the-art property testing for Haskell.
Stars: ✭ 584 (+174.18%)
Mutual labels:  property-based-testing, quickcheck
Quicktheories
Property based testing for Java 8
Stars: ✭ 483 (+126.76%)
Mutual labels:  property-based-testing, quickcheck
Stream data
Data generation and property-based testing for Elixir. 🔮
Stars: ✭ 597 (+180.28%)
Mutual labels:  property-based-testing, quickcheck
Quick check.js
A JS implementation of quick_check
Stars: ✭ 48 (-77.46%)
Mutual labels:  property-based-testing, quickcheck
pbt-frameworks
An overview of property-based testing functionality
Stars: ✭ 29 (-86.38%)
Mutual labels:  quickcheck, property-based-testing
kitimat
A library for generative, property-based testing in TypeScript and Jest.
Stars: ✭ 68 (-68.08%)
Mutual labels:  quickcheck, property-based-testing
efftester
Effect-Driven Compiler Tester for OCaml
Stars: ✭ 37 (-82.63%)
Mutual labels:  quickcheck, property-based-testing
Junit Quickcheck
Property-based testing, JUnit-style
Stars: ✭ 821 (+285.45%)
Mutual labels:  property-based-testing, quickcheck
Qcheck
QuickCheck inspired property-based testing for OCaml.
Stars: ✭ 194 (-8.92%)
Mutual labels:  property-based-testing, quickcheck
Hypothesis
Hypothesis is a powerful, flexible, and easy to use library for property-based testing.
Stars: ✭ 5,571 (+2515.49%)
Mutual labels:  fuzzing, property-based-testing
quick.py
Property-based testing library for Python
Stars: ✭ 15 (-92.96%)
Mutual labels:  quickcheck, property-based-testing
Deepstate
A unit test-like interface for fuzzing and symbolic execution
Stars: ✭ 603 (+183.1%)
Mutual labels:  fuzzing, property-based-testing
Qcstm
A simple state-machine framework for OCaml based on QCheck
Stars: ✭ 50 (-76.53%)
Mutual labels:  property-based-testing, quickcheck

rapid PkgGoDev CI

Rapid is a Go library for property-based testing.

Rapid checks that properties you define hold for a large number of automatically generated test cases. If a failure is found, rapid automatically minimizes the failing test case before presenting it.

Property-based testing emphasizes thinking about high level properties the program should satisfy rather than coming up with a list of individual examples of desired behavior (test cases). This results in concise and powerful tests that are a pleasure to write.

Design and implementation of rapid are heavily inspired by Hypothesis, which is itself a descendant of QuickCheck.

Features

  • Idiomatic Go API
  • Fully automatic minimization of failing test cases
  • Persistence of minimized failing test cases
  • Support for state machine ("stateful" or "model-based") testing
  • No dependencies outside the Go standard library

Examples

Here is what a trivial test using rapid looks like:

package rapid_test

import (
	"net"
	"testing"

	"pgregory.net/rapid"
)

func TestParseValidIPv4(t *testing.T) {
	const ipv4re = `(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])` +
		`\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])` +
		`\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])` +
		`\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])`

	rapid.Check(t, func(t *rapid.T) {
		addr := rapid.StringMatching(ipv4re).Draw(t, "addr").(string)
		ip := net.ParseIP(addr)
		if ip == nil || ip.String() != addr {
			t.Fatalf("parsed %q into %v", addr, ip)
		}
	})
}

You can play around with the IPv4 regexp to see what happens when it is generating invalid addresses (or try to pass the test with your own ParseIP implementation). More complete function (source code, playground) and state machine (source code, playground) example tests are provided. They both fail. Making them pass is a good way to get first real experience of working with rapid.

Usage

Just run go test as usual, it will pick up also all rapid tests.

There are a number of optional flags to influence rapid behavior, run go test -args -h and look at the flags with the -rapid. prefix. You can then pass such flags as usual. For example:

go test -rapid.checks=1000

Comparison

Rapid aims to bring to Go the power and convenience Hypothesis brings to Python.

Compared to gopter, rapid:

  • has a much simpler API (queue test in rapid vs gopter)
  • does not require any user code to minimize failing test cases
  • persists minimized failing test cases to files for easy reproduction
  • generates biased data to explore "small" values and edge cases more thoroughly (inspired by SmallCheck)
  • enables interactive tests by allowing data generation and test code to arbitrarily intermix

Compared to testing/quick, rapid:

  • provides much more control over test case generation
  • supports state machine based testing
  • automatically minimizes any failing test case
  • has to settle for rapid.Check being the main exported function instead of much more stylish quick.Check

Status

Rapid is preparing for stable 1.0 release. API breakage and bugs should be extremely rare.

If rapid fails to find a bug you believe it should, or the failing test case that rapid reports does not look like a minimal one, please open an issue.

License

Rapid is licensed under the Mozilla Public License Version 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].