Best Way to Test your Package



I’ve been working on an Rmarkdown Template Package for a short while and I feel like I’m missing something. Currently whenever I make a change that I want to make sure works what I end up doing is:

  1. Save all the files
  2. Git add, Git Commit, Git push all my files to github
  3. devtools::install_github() my package again to my computer.
  4. Close project and and test knitting a document to see if it worked.

I know I’m missing something. Can someone enlighten me or point me towards some resources on an efficient package development workflow. I’ve seen the Package Development books by Hadley & co. Any other resources?


Hi @dylanjm, the main book I use is this one:, additionally, a look at the tidyverse GitHub repos to learn by example. For testing, the testthat package will be the main vehicle for unit testing, that is described in this section of the book: Another great resource is to add Travis CI integration to your repo, it will test in multiple R versions for you, as well as will run the tests in Linux, here is a great intro guide by @julia :


Sounds like you would enjoy devtools::load_all()! The best explanation of that that I have written is in here:

I do talk about the workflow friction you are suffering from. I think you are asking about test-driving as much or more than actual (unit) testing.


Just wanted to second @edgararuiz’s plug for Travis CI. You can also use Travis to test on Mac at the same time as your Linux tests, and appveyor to test on Windows. That way you can cover all major operating systems! They both work similarly and trigger automatically off of new git commits / pull requests / etc. You can add them to your project easily with usethis::use_appveyor() and usethis::use_travis().

You can add all sorts of fancy (related) badges to your README, as well!


We have a package (INBOmd)[], which sounds very similar: it contains Rmarkdown and LaTeX templates.

We have set up Wercker (linux) and AppVeyor (windows). Both run the standard R CMD check routines after every push to the GitHub repo.

The Wercker version also clones and compiles a github repo called inbomd_examples. If any of those fail to compile then this failure is reported back to GitHub. Successful runs of the examples on the master branch of INBOmd are automatically deployed.

When the runs on the master branch at AppVeyor are successful, the package is automatically deployed (tar.gz and zip) to our drat repository.