Hans-Peter <[EMAIL PROTECTED]> writes:

>> - My code gives error and warning messages in some situations. I want to
>> test that the errors and warnings work, but these flags are the correct
>> response to the test. In fact, it is an error if I don't get the flag.
>> How easy is it to set up automatic tests to check warning and error
>> messages work?
>
> Maybe like this:
>
> ### for errors:
> res1fkt <- function() xls.info( exc )
> res1 <- try( res1fkt(), silent = TRUE )
> if (class( res1 ) != "try-error") stop( "xls.info, data not equal" )
> cat( "REQUIRED (EXPECTED) error message: ", res1  )

Instead, see RUnit's checkException test.  I don't see a checkWarning
test, but imagine it could be added.  Another feature that I imagine
could be added is to actually compare the error/warning message.  I'm
not sure how much benefit there is to that since it basically means
putting the error message in two places, but I suppose it can be
useful to make sure that any formatting of inputs is being done
properly.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

______________________________________________
[email protected] 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.

Reply via email to