[R] Test Driven Development in R
Philippe Grosjean
phgrosjean at sciviews.org
Mon Feb 2 10:37:12 CET 2009
Hello,
As Jose noted, svUnit is fully functional. It is completely written and
has recently entered in beta stage. It will be released on CRAN (GPL >=
2) at the end of the beta test, lasting in October 2009.
svUnit R package is independent from the SciViews GUI, but it is true
there is also a GUI for test-driven development (TDD) in R using svUnit
+ SciViews-K + Komodo, and it works on Linux/Windows/Mac OS X. It is
probably the first one available for R. I am pretty sure other people
will release similar tools for Eclipse/StatET and for Emacs/ESS soon.
The GUI for TDD on top of svUnit depends on SciViews packages that are
in mixed states: some are already on CRAN (svMisc, svSocket, svGUI,
svIDE), while others, like svUnit or svTools are still in, respectively,
beta and alpha stages. You can install them right now from r-forge only.
Use:
> install.packages("svUnit", repos="http://R-Forge.R-project.org")
in R to install svUnit. On Mac OS X, if R cannot find the binaries, make:
> install.packages("svUnit", repos="http://R-Forge.R-project.org",
+ type = "source")
I want to remind also that svUnit is "test code compatible" with RUnit.
Understand: you can use the same test units both with RUnit and with
svUnit (but not simultaneously, of course). I think both packages have
strengths. RUnit has (experimental) functions to check code coverage of
the tests, while svUnit is much more flexible to define the tests: they
can be attached to R objects, on memory, or on a .R file, they can be
independent objects, and of course, they can also be contained in test
suite on disk files, like for Runit. Also, svUnit proposes a mechanism
to automatically locate tests, test units and test suites. It also
proposes a central logging feature collecting test results from
different test runs, and it fully integrates with the R CMD check
mechanism of R for packages checking. Finally, svUnit reports can be
pretty formatted using creole wiki language and be integrated in wikis
(like http://wiki.r-project.org), say for automatic nightly test of your
code. See page 9 of the svUnit vignette for an example.
It is this additional flexibility that is exploited in the GUI part for
TDD in SciViews-K. There is a vignette associated with the svUnit
package detailing all its features. Just make:
library(svUnit)
vignette("svUnit")
once the svUnit package is installed in R.
We will be happy to receive comments, bug reports and other suggestions
during this beta test. Use the bug and suggestions tracker on:
https://r-forge.r-project.org/tracker/?group_id=194
Otherwise, I plan to submit an abstract about svUnit to User!2009 soon.
All the best,
Philippe Grosjean
..............................................<°}))><........
) ) ) ) )
( ( ( ( ( Prof. Philippe Grosjean
) ) ) ) )
( ( ( ( ( Numerical Ecology of Aquatic Systems
) ) ) ) ) Mons-Hainaut University, Belgium
( ( ( ( (
..............................................................
Tobias Verbeke wrote:
> Jose Quesada wrote:
>
>> Hi,
>> I wonder what kind of interest there is on Test Driven Development
>> (TDD) in R.
>>
>> Test Driven Development consists of writing the test before the
>> function, and iteratively build the function until it passes the test.
>>
>> Python and Ruby (specially Ruby) have very strong test-oriented
>> cultures. In fact, in Ruby at least the custom is to do TDD and lately
>> Behavior-driven development (BDD). In BDD, one writes a story of what
>> one would want the code to do. This story is almost native English,
>> and then the test suite converts it into something that the language
>> understand as tests.
>>
>> There are some posts on the list about this, but they are about
>> testing in general (Runit), not TDD. Example:
>> http://thread.gmane.org/gmane.comp.lang.r.general/85047
>>
>> Recently, I found there is an alpha, but working implementation of TDD
>> for Komodo edit:
>> www.sciviews.org/SciViews-K/index.html
>>
>> The editor has a green bar that becomes red as soon as one edits a
>> function, and that edit breaks the tests. This is tremendously useful.
>>
>> Using Gmane search, the only mention I could find on svUnit was:
>> http://thread.gmane.org/gmane.comp.lang.r.general/136632/focus=136662
>>
>> I think this could make a great UseR 2009 talk. Ideally, by someone
>> with more R experience than me, and even more ideally by Philippe
>> Grosjean :), but it push comes to shove, I could prepare such a talk.
>>
>> Would this be interesting at all? Are there any resources that I have
>> missed?
>
> There is the RUnit package which is a mature xUnit implementation for R.
>
> I don't know of a tight integration into an editor (apart from
> that it is _planned_ for StatET, the Eclipse R plug-in), but
> as such it is very useful already.
>
> http://cran.r-project.org/web/packages/RUnit/index.html
>
> HTH,
> Tobias
>
> ______________________________________________
> R-help at r-project.org 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.
>
>
More information about the R-help
mailing list