I have a collection of functions, class definitions and methods which I would like to test systematically for their correctness after changes to their code, and also after major R revisions. I believe that the correct term for these systematic tests (as opposed to more informal tests) is a 'test suite'. Does anyone [apart from Pat Burns :-) ] have code, or templates, or specific suggestions for the best approach to constructing test suites? Thanks in advance Giles Heywood
"all.equal" described in Venables and Ripley (MASS, 4th ed., p. 49, and S Programming, p. 21) is useful. (The index entry in "S Programming is off by 1 page.) Hope this helps. Spencer Graves Giles Heywood wrote:> I have a collection of functions, class definitions and methods which I > would like to test systematically for their correctness after changes to > their code, and also after major R revisions. I believe that the correct > term for these systematic tests (as opposed to more informal tests) is a > 'test suite'. Does anyone [apart from Pat Burns :-) ] have code, or > templates, or specific suggestions for the best approach to constructing > test suites? > > Thanks in advance > > Giles Heywood > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help
Perhaps the best way to do this is to make up an R package. The "Writing R Extensions" manual has discussions on how to set up test codes. There are also examples in some packages that shipped with R itself. Look in the `check' subdirectory of packages under .../R-1.6.2/src/library. Andy> -----Original Message----- > From: Giles Heywood [mailto:giles.heywood at btinternet.com] > Sent: Monday, February 24, 2003 3:48 PM > To: r-help at stat.math.ethz.ch > Subject: [R] Test suites > > > I have a collection of functions, class definitions and > methods which I > would like to test systematically for their correctness after > changes to > their code, and also after major R revisions. I believe that > the correct > term for these systematic tests (as opposed to more informal > tests) is a > 'test suite'. Does anyone [apart from Pat Burns :-) ] have code, or > templates, or specific suggestions for the best approach to > constructing > test suites? > > Thanks in advance > > Giles Heywood > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >------------------------------------------------------------------------------
Well, R itself has lots of tests in its test suite (see directory tests in the sources) as well as a mechanism for running test suites in packages: recommended packages nlme and rpart have them, for example. So I suggest just adding a test suite to your package (this *is* a package, I hope) and running R CMD check on it. It's documented in `Writing R Extensions'. On Mon, 24 Feb 2003, Giles Heywood wrote:> I have a collection of functions, class definitions and methods which I > would like to test systematically for their correctness after changes to > their code, and also after major R revisions. I believe that the correct > term for these systematic tests (as opposed to more informal tests) is a > 'test suite'. Does anyone [apart from Pat Burns :-) ] have code, or > templates, or specific suggestions for the best approach to constructing > test suites?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595