I think the OP was asking about test suites that test the software.

The R package structure includes a test/ directory which you can use
to put tests.

For example, in the onion package I check that I have got my
signs and multiplication table correctly implemented:

 stopifnot(Hi*Hj ==  Hk)
 stopifnot(Hj*Hi == -Hk)
 stopifnot(Hj*Hk ==  Hi)
 stopifnot(Hk*Hj == -Hi)
 stopifnot(Hk*Hi ==  Hj)
 stopifnot(Hi*Hk == -Hj)

[and a whole lot of others]

and the elliptic package includes a whole bunch of code
that verifies identities that appear in AMS-55.  It also
includes numerical  verification that the functions,
using randomish arguments, match the output of
mathematica or maple.





Philippe Grosjean wrote:
There is a mechanism for testing code in R packages (R CMD check), see the Writing R extensions manual. If you need more flexibility for your tests, you could look at RUnit on CRAN, or svUnit on R-Forge (http://r-forge.r-project.org, on CRAN soon). For the later one, you install it by:

install.packages("svUnit", repos="http://R-Forge.R-project.org";)

These is a vignette associated with svUnit:

vignette("svUnit")

Note that RUnit and svUnit are "test suite code" compatible, but they use very different mechanisms internally.
Best,

Philippe Grosjean

..............................................<°}))><........
 ) ) ) ) )
( ( ( ( (    Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (    Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Belgium
( ( ( ( (
..............................................................

Nathan S. Watson-Haigh wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was wondering if anyone could point me in the right direction for reading up on writing tests in R. I'm writing some functions for inclusion into a package and would like to test them to ensure
they're doing what I expect them to do.

Are these approaches used for testing packages in CRAN?

Cheers,
Nathan


- --
- --------------------------------------------------------
Dr. Nathan S. Watson-Haigh
OCE Post Doctoral Fellow
CSIRO Livestock Industries
Queensland Bioscience Precinct
St Lucia, QLD 4067
Australia

Tel: +61 (0)7 3214 2922
Fax: +61 (0)7 3214 2900
Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
- --------------------------------------------------------

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkluio8ACgkQ9gTv6QYzVL5X9QCgwvg5xjwZW2A2Z5G41iADu1Kz
hIkAoI5ISuAtHyQ+JwJSRBAc9q/oyeEt
=cqm4
-----END PGP SIGNATURE-----

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to