drakepkg icon indicating copy to clipboard operation
drakepkg copied to clipboard

drake using testthat

Open feinmann opened this issue 5 years ago • 3 comments

Are there examples how to implement tests using testthat and drake?

feinmann avatar Nov 28 '19 12:11 feinmann

@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.

wlandau avatar Nov 30 '19 05:11 wlandau

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.

lbusett avatar Dec 02 '19 13:12 lbusett

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.

wlandau avatar Dec 03 '19 17:12 wlandau