r - Debugging 'testthat' tests in RStudio -


is possible invoke debugger in rstudio when running testthat tests? haven't been able find setup allows (various combinations of "use devtools package functions if available" in settings, hitting "test package" option in "build -> more" menu, running test() in console, putting in browser() calls, etc.) haven't found way yet.

i find myself getting lost lot when testing, unsure whether code being run has been installed in system libraries (by doing 'build & reload'), or being run in situ local r directory, or - rstudio complains breakpoint can't set until package rebuilt (so suspect former) or doesn't (so suspect latter). not sure if issue closely related or not main question.

without finding way drop debugger, end pasting test code console & working in ad-hoc fashion, , shooting tdd habits in foot. advice appreciated - if it's not possible invoke debugger, suggested workarounds?

i'm running rstudio version 0.99.447 on os x, in local mode, r 3.2.1.

edit - i'd love know more background options, e.g. "option x never support debugging, because it's running in forked process, try other option y instead."

update - having had no responses here, asked @ https://support.rstudio.com/hc/communities/public/questions/204779797-debugging-testthat-tests-in-rstudio (where haven't had responses).

the following works me:

  1. insert call browser() somewhere within testthat unit tests.
  2. run devtools::test() rstudio console (instead of using "test package" menu item ui)

then, when test runner hits browser() invocation, should able use environment browser , step through code.

i haven't found way testthat stop @ breakpoints, inserting browser() invocations pretty close substitute.

to absolutely sure you're starting consistent state when comes loading packages, can close rstudio, re-open it, run "clean , rebuild", , devtools::test()

lastly, if you're working within rstudio package, may want check out following advice rstudio support:

in order debug in package, you’ll want ensure package compiled --with-keep.source option. option default new packages in rstudio; if need set manually, can found in tools -> project options -> build tools.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -