[Rcpp-devel] How to manage testing code for Rcpp based project?

Douglas Bates bates at stat.wisc.edu
Wed Aug 22 18:25:14 CEST 2012

On Wed, Aug 22, 2012 at 12:16 AM, Davor Cubranic <cubranic at stat.ubc.ca> wrote:
> On 12-08-21 09:54 PM, Darren Cook wrote:
>>>> RUnit works, but the setup is not the easiest. If someone has ideas for
>>>> better solutions, by all means implement those.  Unit testing has helped
>>>> us
>>>> many times, and I consider it to be a very important part of package
>>>> development.
>>> How (or in what aspect) RUnit is better than devtools?
>> What is "devtools"? Is it a package for testing R software? (it sounds
>> more generic)
> See http://cran.r-project.org/web/packages/devtools/ and
> https://github.com/hadley/devtools
> It aims to make various phases of package development cycle easier, at the
> expense of requiring following certain conventions about naming and layout
> of source files and directories.
> I think what Peng meant as an alternative to Runit is not the devtools
> itself, but testthat. See http://cran.r-project.org/web/packages/testthat/
> and https://github.com/hadley/test_that
> Philosophically, testthat draws on Ruby test frameworks like rspec and other
> BDD tools. In practical terms, it means that the tests look like this:
> context("Basic tests")
> test_that("logical tests act as expected", {
>   expect_that(TRUE, is_true())
>   expect_that(FALSE, is_false())
> })
> test_that("equality holds", {
>   expect_that(5, equals(5))
>   expect_that(10, is_identical_to(10))
> })
> I haven't gotten very deep into using it, but in practical terms I find
> there is almost 1:1 correspondence in testing functions ("checkEquals" ->
> "expect_that(..., equals(...))", with testthat being a little more readable
> but requiring me to turn off ESS's smart-underscore. :-)

In the past it was difficult to have tests run through testthat use
the inline package because the two packages disagreed on the current
working directory.  Not sure if that has changed.

More information about the Rcpp-devel mailing list