[R] Test Driven Development in R

Tobias Verbeke tobias.verbeke at openanalytics.be
Sat Jan 31 16:42:01 CET 2009


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




More information about the R-help mailing list