[Rd] test suites for packages

Claudia Beleites claudia.beleites at ipht-jena.de
Wed May 23 18:47:04 CEST 2012


I use svUnit, too.

I put a kind of standard skeleton into my packages that has a
packagename.unittest () function that will run all svUnit tests (if
svUnit is available). This function returns NA if svUnit is not
available, invisible (TRUE) if all tests are passed and  stops
otherwise. Which will cause R CMD check to fail.

My test directory contains one single tests.R file with the two lines:

library (packagename)
packagename.unittest ()


which gives me e.g.:

Running the tests in ‘tests/tests.R’ failed.
Last 13 lines of output:
    only logical matrix subscripts are allowed in replacement

  * :     ...) ... **ERROR**
  Error in `[<-.data.frame`(`*tmp*`, x.na, value = NA) :
    only logical matrix subscripts are allowed in replacement
                           kind timing                time unit msg
  test(kernelpls.fit)        OK  0.009 2012-05-23 14:38:49
  test(scale)                OK  0.009 2012-05-23 14:38:49
  test(.ldapreproc)   **ERROR**  0.007 2012-05-23 14:38:49
  test(pcalda)               OK  0.003 2012-05-23 14:38:49
  Error in errorLog(summarize = FALSE) : 0 failure(s) and 1 error(s)
  Calls: cbmodels.unittest -> errorLog
  Execution halted


While the 13 lines may not be enough if there are lots of tests, I can
easily run packagename.unittest () in an interactive session and start
tracking down the problem from there.


Claudia


Am 18.05.2012 17:28, schrieb Cook, Malcolm:
> svUnit - is Runit compatible and provides some  IDE integration and report
> generation and easy syntax for defining tests.
> 
> I find it works a treat, and fits very nicely with my R coding/packaging
> style (which also uses inlinedocs for easy package creation).
> 
> --Malcolm Cook
> 
> 
> On 5/17/12 9:10 AM, "Whit Armstrong" <armstrong.whit at gmail.com> wrote:
> 
>> Can anyone share some opinions on test suites for R packages?
>>
>> I'm looking at testthat and RUnit. Does anyone have strong opinions on
>> either of those.
>>
>> Any additional packages I should consider?
>>
>> Thanks,
>> Whit
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


-- 
Claudia Beleites
Spectroscopy/Imaging
Institute of Photonic Technology
Albert-Einstein-Str. 9
07745 Jena
Germany

email: claudia.beleites at ipht-jena.de
phone: +49 3641 206-133
fax:   +49 2641 206-399



More information about the R-devel mailing list