Skip to content

Conversation

@tomjemmett
Copy link
Member

  • eliminates any stub calls, favouring local_mocked_bindings
  • uses withr::local_seed rather than set.seed
  • adds bindings to some base functions so we can mock these in tests

- eliminates any stub calls, favouring local_mocked_bindings
- uses withr::local_seed rather than set.seed
- adds bindings to some base functions so we can mock these in tests
@tomjemmett tomjemmett requested a review from matt-dray as a code owner February 5, 2026 17:05
Copilot AI review requested due to automatic review settings February 5, 2026 17:05
@tomjemmett tomjemmett requested a review from DCEW as a code owner February 5, 2026 17:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors test code to use modern testthat best practices by replacing stub calls with local_mocked_bindings and set.seed with withr::local_seed. The changes ensure automatic cleanup after tests and improve test isolation.

Changes:

  • Replaced all stub calls with local_mocked_bindings for better automatic cleanup
  • Replaced set.seed with withr::local_seed to ensure seed is automatically reset
  • Added bindings for base R functions (system.file, file.exists) in R/ZZZ.R to enable mocking

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/testthat/test-utils_server.R Converted stub calls to local_mocked_bindings for AzureAuth and AzureStor functions
tests/testthat/test-utils_data.R Converted stub call for file.exists to local_mocked_bindings
tests/testthat/test-fct_table.R Replaced set.seed with withr::local_seed
tests/testthat/test-fct_plots.R Replaced set.seed with withr::local_seed
tests/testthat/test-app_server.R Converted mockery::stub call to local_mocked_bindings for bslib function
tests/testthat/test-add_external_resources.R Converted stub call for system.file to local_mocked_bindings
R/ZZZ.R Added NULL bindings for base R functions (system.file, file.exists) to enable mocking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@matt-dray matt-dray removed the request for review from DCEW February 5, 2026 18:21
Copy link
Contributor

@matt-dray matt-dray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey-doke, thanks, happy to go with your suggestions.

After merge I'm going to un-release 0.3.4 and re-release with this included.

@tomjemmett
Copy link
Member Author

I wouldn't worry too much about re-releasing, these are just minor changes!

@tomjemmett tomjemmett merged commit 616fcbc into main Feb 5, 2026
8 checks passed
@tomjemmett tomjemmett deleted the refactor_tests branch February 5, 2026 18:31
@matt-dray matt-dray added enhancement New feature or request priority: should MoSCoW priority labels Feb 5, 2026
@matt-dray matt-dray modified the milestones: v0.3.4, v0.3.5 Feb 5, 2026
@matt-dray matt-dray modified the milestones: v0.3.5, v0.4.0 Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: should MoSCoW priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants