1

I have a markdown script with several code chunks and providing this script together with my package. I want to include unit testing for these code chunks or any way to make sure, my markdown script is always running.

Has anyone tried something before or can recommend a way of testing the markdown script?

drmariod
  • 11,106
  • 16
  • 64
  • 110

1 Answers1

2

I use a function called runAllChunks to run R code from an RMD file. I stole the function from knitr: run all chunks in an Rmarkdown document. That might be helpful in your situation.

Community
  • 1
  • 1
Benjamin
  • 16,897
  • 6
  • 45
  • 65
  • I try to put the `runAllChunks` function into an `expect_that` function to test if it runs through with my default setting, but `runAllChunks` does not return anything. Would it be save to just return `TRUE` at the end of the function, because if it fails it will produce an error anyways. What do you think or how did you solve this? – drmariod Sep 01 '15 at 09:10
  • 1
    Or you could use `expect_that(runAllChunks(...), not(throws_error()))`. – Benjamin Sep 01 '15 at 10:05