-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: use_test_helper() #1822
Comments
I agree. I think it may be a little bit less straightfoward than the other 2 ( Should there be an option for a generic test helper Also, important to note that |
I made a little sketch. I don't really like that the default isn't consistent with the default of Lines 57 to 71 in fdb4a72
#' @rdname use_r
#' @export
#' @param scope if global, creates "tests/testthat/helper.R", otherwise creates
#' "tests/testthat/helper-{name}.R
use_test_helper <- function(name = NULL, scope = c("global", "file"), open = rlang::is_interactive()) {
if (!uses_testthat()) {
use_testthat_impl()
}
scope <- arg_match(scope)
if (scope == "global") {
path <- path("tests", "testthat", "helper", ext = "R")
} else {
path <- path("tests", "testthat", paste0("helper-", compute_name(name)))
}
edit_file(proj_path(path), open = open)
ui_bullets(c(
"_" = "Run {.run devtools::load_all()} to load objects from helper files in
your environment."
)
)
invisible(TRUE)
} |
I'm generally on board, so am happy to see this in PR form. I'm not sure the |
I really enjoy using
use_test()
anduse_r()
, but was wondering whether there could be an equivalent for creating atests/testthat/helper-
file? (I didn't find any related issue but might have missed one 😅)The text was updated successfully, but these errors were encountered: