[Bioc-devel] writing unit tests for functions in an initializer

Zach Skidmore zskidmor at wustl.edu
Thu Sep 28 16:48:09 CEST 2017


Hi All,

I maintain the GenVisR package and am currently converting it to S4 classes. I'm running into a problem however when writing unit tests for functions within the initalizer. What I really need is a "mock" object of the class for which the initializer unit tests are being performed but which hold no data. This will allow me to step through the initializer "sub functions" and write tests for each one. The problem is I don't see a way in the S4 system to create a mock object. I've found this post that will do what I want http://r.789695.n4.nabble.com/Using-a-mock-of-an-S4-class-td4728547.html, however when using this solution R CMD CHECK throws errors:

* checking dependencies in R code ... WARNING
Unexported object imported by a ':::' call: ‘methods:::C_new_object’
  See the note in ?`:::` about the use of this operator.
  Including base/recommended package(s):
  ‘methods’
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... WARNING
Foreign function call to a base package:
  .Call(methods:::C_new_object, ...)
Packages should not make .C/.Call/.External/.Fortran calls to a base
package. They are not part of the API, for use only by R itself and
subject to change without notice.

I'm wondering if anyone has any ideas on the best way to handle this. I suppose i could create a "test" flag within the initalizer that would create an empty object of that class and use that but it seems hacky to do this.

thanks!
Zach

________________________________
The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list