##Unit Tests for Programming Assignment 3
This project is an implementation of testthat
unit tests for the Coursera R Programming course Assignment 3. 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 3.
---|--------------------|------------------------------|---------------------------------------------
1 | best
| Finding the best hospital in a state | test-best.r
2 | rankhospital
| Ranking hospitals by outcome in a state | test-rankhospital.r
3 | rankall
| Ranking hospitals in all states | test-rankall.r
source
the script for the assignment into your R working environment.
- E.g.,
> source("best.R")
source
the matchingtestthat
script into your environment.
> source("test-best.r")
>
- Notice how unobtrusive
testthat
is, if there is no error.
You can also run scripts using the test_file
function.
> test_file("test-best.r")
Finding the best hospital in a state : .....
>
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