drakepkg
drakepkg copied to clipboard
drake using testthat
Are there examples how to implement tests using testthat and drake?
@lbusett floated this idea back in early 2018 (https://github.com/ropensci/drake/issues/206 and https://github.com/lbusett/draketest) but traction seems to have waned for now.
Yes, I did some preliminary work on that, but then unfortunately I was not able to bring it any further.
For reference, what I was struggling with at the time was in "recognizing" the dependencies of the various tests to the different functions in a package (so that a change in a function led to invalidation of the corresponding test results), and in scraping somehow the contents of the various test files, to allow each testthat::expect_....
to become a separate target.
For reference, what I was struggling with at the time was in "recognizing" the dependencies of the various tests to the different functions in a package (so that a change in a function led to invalidation of the corresponding test results)...
Yeah, there are some counterintuitive requirements for this. For one, we need expose_imports()
to tell drake
to look in the package for functions that change.
...and in scraping somehow the contents of the various test files, to allow each testthat::expect_.... to become a separate target.
What if each test_that()
call is a target? Seems a bit more natural. Related: https://books.ropensci.org/drake/plans.html#how-to-choose-good-targets.