[R-pkg-devel] Hedgehog property based testing
Huw Campbell
huw.campbell at gmail.com
Fri Feb 9 14:38:50 CET 2018
Hi all,
I have ported hedgehog, a property based testing library
<https://github.com/hedgehogqa/r-hedgehog> from Haskell to R, and would
really like folks to use it and test the API hard before I release it on
CRAN. I have been using it with great success for my projects for a while;
and have also uncovered a few real bugs in R libraries in the wild.
Hedgehog is similar to *quickcheck* in philosophy and fully compatible with
Hadley Wickham's *testthat* library, so should be easy to integrate. The
idea is to write property tests like this:
test_that("Reverse of reverse is identity",
forall(gen.c(gen.element(1:100)), function(xs) expect_equal(rev(rev(xs)), xs))
)
Give it a shot and please do hit me up with any questions.
For all that I like about R, I think it can be tough to write robust
code which handles all the edge
cases one could throw at it, so great testing is invaluable.
Cheers,
Huw
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list