quickcheck
Overview
Property based testing in R, inspired by
QuickCheck. This package
builds on the property based testing framework provided by
hedgehog and is designed
to seamlessly integrate with testthat.
Installation
You can install the released version of quickcheck from
CRAN with:
install.packages("quickcheck")And the development version from GitHub with:
# install.packages("remotes")
remotes::install_github("armcn/quickcheck")Usage
The following example uses quickcheck to test the properties of the
base R + function.
Here
is an introduction to the concept of property based testing, and an
explanation of the mathematical properties of addition can be found
here.
library(testthat)
library(quickcheck)
test_that("0 is the additive identity of +", {
for_all(
a = numeric_(len = 1),
property = function(a) expect_equal(a, a + 0)
)
})
#> Test passed