A sample package in R
Install devtools
and testthat
:
install.packages('devtools')
install.packages('testthat')
Load devtools
library:
library(devtools)
Create basic testing infrastructure:
# navigate to your project dir
setwd('path/to/project')
test('.') # will ask you to create testing infrastructure, press 1 Enter
Create tests in files named test*.R
inside tests/testthat
,
and run again test('.')
.
See the docs of testthat on how to write unit tests.