From rossini at blindglobe.net  Thu Mar 18 00:57:46 2004
From: rossini at blindglobe.net (A.J. Rossini)
Date: Thu Mar 18 00:56:14 2004
Subject: [Rd] unit testing framework for R?
In-Reply-To: <029D5E4CC620344D9A54430DABC37F4307B704@BOC-EXMAIL1.bocad.bank-banque-canada.ca>
	(Paul Gilbert's message of "Wed, 17 Mar 2004 18:02:39 -0500")
References: <029D5E4CC620344D9A54430DABC37F4307B704@BOC-EXMAIL1.bocad.bank-banque-canada.ca>
Message-ID: <85oeqvdo1x.fsf@servant.blindglobe.net>

"Paul Gilbert" <pgilbert@bank-banque-canada.ca> writes:

> I am interested in this, but there is already a fair amount that can
> be accomplished within the existing framework. I do something I think
> of as unit testing, but my code chunks are packages rather than
> functions. This does not have to be reactive. With a proper makefile
> setup it can be proactive.

Correct -- it's the interface.

> Within a package it should be possible to reflect some of the
> dependancy structure simply by a naming convention like tests/01test,
> tests/02othertest, tests/03moretests ....

That would be the next step -- what we actually do is have functions
in the tests/ directory, along with a possible external flag variable
which if bound, disables the automatic evaluation of the functions and
instead lets one pick a suite of functions.

So our hacks are basically:

1. use a possibly bound variable to determine if we evaluate
everything (CMD check) or just pieces (test(c(1,2,10))

2. create an instance of a class that describes this.

3. have methods for the class that automate the evaluation.

> I am not sure how much will be gained by automatically generating
> comparison files for the tests. Most of my tests are based on
> computing numeric values, doing a comparison with known values, and
> executing stop()if there is a problem. If you could generate those
> kind of comparisons automatically, then that would be terrific.

I'm not constructing comparison files for the tests -- I'm
testing results against previous stored results and returning a
boolean value indicating if there is a pass.

And its a hack since we don't do it automagically (or rather,
automagically via a "sample" observation of the function's parse
tree).

One of these days I'll clean it up, but I suspect that someone will
implement it right before I get around to it (post Bioconductor
release).

best,
-tony

-- 
rossini@u.washington.edu            http://www.analytics.washington.edu/ 
Biomedical and Health Informatics   University of Washington
Biostatistics, SCHARP/HVTN          Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC  (M/W): 206-667-7025 FAX=206-667-4812 | use Email

CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}


[Rd] unit testing framework for R?
A.J. Rossini