Skip to content
Prev 43408 / 63424 Next

test suites for packages

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: