Is it possible to invoke the debugger in RStudio when running testthat
tests? I haven't been able to find a setup that allows this (various combinations of "use devtools
package functions if available" in the settings, hitting the "Test Package" option in the "Build -> More" menu, running test()
in the console, putting in browser()
calls, etc.) but haven't found a way yet.
I also find myself getting lost a lot when testing, unsure whether the code being run has been installed in the system libraries (by doing 'Build & Reload'), or is being run in situ from the local R
directory, or what - sometimes RStudio complains that a breakpoint can't be set until the package is rebuilt (so I suspect the former) or doesn't (so I suspect the latter). Not sure if this issue is closely related or not to my main question.
Without finding a way to drop into the debugger, I end up pasting test code into the console & working in a very ad-hoc fashion, and basically shooting my TDD habits in the foot. So any advice would be appreciated - if it's not possible to invoke the debugger, any suggested workarounds?
I'm running RStudio version 0.99.447 on OS X, in local mode, with R 3.2.1.
Edit - I'd also love to know more background about the options, e.g. "option X will never support debugging, because it's running in a forked process, try this other option Y instead."
Update - having had no responses here, I also asked at https://support.rstudio.com/hc/communities/public/questions/204779797-Debugging-testthat-tests-in-RStudio (where I also haven't had any responses).
dev_mode
is one solution but sometimes I forget to turn that on too, since it's a manual process... – Metathesis