##Unit Tests for Programming Assignment 1
This project is an implementation of testthat
unit tests for the Coursera R Programming course Assignment 1. The testthat
package was written by Hadley Wickham to enable unit testing of the 'stringr' string manipulation package during development. The unit tests implement the examples given in the Instructions for Programming Assignment 1.
---|--------------------|------------------------------|---------------------------------------------
1 | pollutantmean
| Calculate the mean of a pollutant | test-pollutantmean.r
2 | complete
| Report the number of complete cases | test-complete.r
3 | corr
| Calculate the correlation between two pollutants | test-corr.r
source
the script for the assignment into your R working environment.
- E.g.,
> source("pollutantmean.R")
source
the matchingtestthat
script into your environment.
> source("test-pollutantmean.r")
>
- Notice how unobtrusive
testthat
is, if there is no error.
You can also run scripts using the test_file
function.
> test_file("test-pollutantmean.r")
Calculate the mean of a pollutant across a specified list of monitors : .....
>
A little more verbose, but still pretty quiet.
For more information on the testthat
package see,
- testthat: Get Started with Testing, R Journal, June 2011.
- CRAN package, testthat