[R] RUnit and tracing errors

Ken Williams ken.williams at thomson.com
Tue Aug 28 21:37:30 CEST 2007


What's a good way to quickly determine the location of a failure in my RUnit
test suite?  For instance, if I do the following:

> library(RUnit)
> runTestSuite( defineTestSuite("MyTests", "src/r", testFuncRegexp="metrics") )

Executing test function test.metrics  ... Timing stopped at: 0.461 0.041 0.5
0 0 
Error in checkEquals(m$meanBPrefB, mean(c(33/100, 16/49))) :
    Mean relative  difference: 0.3516807
 done successfully.

Number of test functions: 1
Number of errors: 0
Number of failures: 1

That doesn't give me any indication of where in test.metrics() the failure
was, so I generally end up inserting debug print statements, or loading my
test file directly and debugging the test.metrics function, or similar.

Is there any RUnit function analogous to traceback(), or a way to
interrogate the result of runTestSuite() to show me a stack trace?

I understand I can get a stack trace for an error, but I don't see a way to
get one for a failure.


Ken Williams
Research Scientist
The Thomson Corporation
Eagan, MN

More information about the R-help mailing list