From phgrosjean at sciviews.org  Tue Oct  6 01:43:42 2009
From: phgrosjean at sciviews.org (Philippe Grosjean)
Date: Tue, 06 Oct 2009 01:43:42 +0200
Subject: [Rd] unit testing for R packages?
In-Reply-To: <486f230c0910051248xd9d9ab9ie3ac6358184e2989@mail.gmail.com>
References: <6c35a4fc0910051201h23e61e39o55bf1de9809bfe29@mail.gmail.com>
	<486f230c0910051248xd9d9ab9ie3ac6358184e2989@mail.gmail.com>
Message-ID: <4ACA84AE.5050708@sciviews.org>

Hi,

I am the writer of svUnit. My initial goal was to build functions on top
of RUnit which is older, and certainly deserves all the credit for core
test unit functions. Unfortunately, the way RUnit is working internally
did not allowed me to build the extensions I needed.

Now, as Seth already told, there are several functions in svUnit that
ease interactive use of the tests in an R session. What he did not told
is that RUnit has some nice code coverage functions that svUnit does not
have.

Thus, not easy to decide... The good news is that both RUnit and svUnit
are almost completely compatible with test unit code, that is, the same
code put in inst/unitTests should run with both packages. So, you could
write your test units, try both approaches in practice, and finally
decide after a little bit of experiment which one you prefer (at least,
read the vignette of each packages).

In case you use Komodo Edit as R code editor, there is a nice GUI
interactive panel to svUnit available (see
http://www.sciviews.org/SciViews-K).

Best,

Philippe Grosjean

Seth Falcon wrote:
> Hi,
> 
> On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
> <blair.christian at gmail.com> wrote:
>> I'm interested in putting some unit tests into an R package I'm
>> building.  I have seen assorted things such as Runit library, svUnit
>> library, packages
>> with 'tests' directories, etc
>>
>> I grep'd "unit test" through the writing R extensions manual but didn't find
>> anything.  Are there any suggestions out there?  Currently I have
>> several (a lot?) classes/methods that I keep tinkering with, and I'd
>> like to run a script frequently to check that I don't cause any
>> unforeseen problems.
> 
> I've had good experiences using RUnit.  To date, I've mostly used
> RUnit by putting tests in inst/unitTests and creating a Makefile there
> to run the tests.  You should also be able to use RUnit in a more
> interactive fashion inside an interactive R session in which you are
> doing development.
> 
> The vignette in svUnit has an interesting approach for integrating
> unit testing into R CMD check via examples in an Rd file within the
> package.
> 
> + seth
>



[Rd] unit testing for R packages?
Philippe Grosjean