-----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-----
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 at 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. > >
Hi Nathan, in addition to what others have already mentioned there is some documentation in the Writing R Extensions Manual: - on the supported structure of packages, indicating where test code might be added http://stat.ethz.ch/R-manual/R-patched/doc/manual/R-exts.html#Package-subdirectories - and the recommended standard approach to check a package http://stat.ethz.ch/R-manual/R-patched/doc/manual/R-exts.html#Checking-and-building-packages and a wiki article on how to combine the standard check (viz R CMD check) with any of the unit testing approaches http://wiki.r-project.org/rwiki/doku.php?id=developers:runit&s=unit%20test Examples for the standard approach employed by R can be found in the R source repository https://svn.r-project.org/R/trunk/src/library/stats/tests/ and for unit test based checking e.g. Rmetrics http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/?root=rmetrics or BioConductor examples https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Biobase/inst/UnitTests/ where you need the access info provided here http://wiki.fhcrc.org/bioc/DeveloperPage Regards, Matthias Nathan S. Watson-Haigh wrote:> 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 > >______________________________________________ R-help at 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. -- Matthias Burger Project Manager/ Biostatistician Epigenomics AG Kleine Praesidentenstr. 1 10178 Berlin, Germany phone:+49-30-24345-371 fax:+49-30-24345-555 http://www.epigenomics.com matthias.burger at epigenomics.com -- Epigenomics AG Berlin Amtsgericht Charlottenburg HRB 75861 Vorstand: Geert Nygaard (CEO/Vorsitzender) Oliver Schacht PhD (CFO) Aufsichtsrat: Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender)