Skip to content
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

Include space for {with,local}_mocked_bindings() placeholders in $package-package.R? #1902

Open
MichaelChirico opened this issue Oct 21, 2023 · 1 comment
Labels
code 🖥️ R/, tests/ feature a feature request or enhancement

Comments

@MichaelChirico
Copy link
Contributor

{testthat} 3.2.0 includes a new evolution for mocking in tests: with_mocked_bindings() and local_mocked_bindings().

One aspect of this is we're encouraged to add placeholders for {base}-mocked functions in our package namespace:

To mock a function in the base package, you need to make sure that you have a binding for this function in your package. It's easiest to do this by binding the value to NULL.

As a package grows/the number of base functions to mock becomes scattered throughout the package, confusion may ensue. This reminds me of how use_package_doc() allots space in the template file for all the #' @import / #' @importFrom tags to live:

## usethis namespace: start
## usethis namespace: end

Should use_package_doc() now also set aside some space for mocked binding {base} placeholders as well?

@hadley
Copy link
Member

hadley commented Nov 3, 2023

I like this idea

@hadley hadley added feature a feature request or enhancement code 🖥️ R/, tests/ labels Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code 🖥️ R/, tests/ feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants