[R-pkg-devel] Interpret feedback: not write testthat-tests in examples

Mark van der Loo m@rk@v@nder|oo @end|ng |rom gm@||@com
Thu Jul 16 15:45:52 CEST 2020


Dear Richel,

The comment itself is pretty clear I think: to be accepted on CRAN you
should not use testthat tests in your examples.

I can't speak for CRAN but I'm pretty convinced this is for testing in
general.

Tests are for testing, not for demonstration. Most users of your package
will probably have never heard of testthat because they are not package
authors. They also probably don't need testthat to use your package, so it
distracts them from learning how your package works. Packages like testthat
(and RUnit, unity and tinytest) are in the first place aimed at package
authors to make sure that their package works as it should and to avoid
re-introducing bugs (regressions).



Best,
Mark




On Thu, Jul 16, 2020 at 3:28 PM Richel Bilderbeek <
richel using richelbilderbeek.nl> wrote:

> Dear R package developers,
>
> I would enjoy some help regarding some feedback I got on my package from a
> CRAN volunteer, as I am unsure how to interpret this correctly.
>
> This is the feedback I got (I added '[do]'):
>
> > Please [do] not write testthat-tests in your examples.
>
> I wonder if this is about using `testthat` or using tests in general.
>
> To simplify the context, say I wrote a package with a function called
> `add`, that adds two numbers. My example code would then be something like
> this:
>
> ```
> library(testthat)
>
> expect_equal(add(1, 2), 3)
> ```
>
> The first interpretation is about using `testthat`: maybe I should use
> base R (`stopifnot`) or another testing library (`testit`) or hand-craft it
> myself?
>
> The second interpretation is about using tests in example code. I like to
> actively demonstrate that my code works as expected. I checked the policies
> regarding examples, and I could not find a rule that I should refrain from
> doing so.
>
> What is the correct response to this feedback?
>
> Thanks for your guidance, Richel Bilderbeek
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list