Skip to content

Add tests for theme/aesthetic helper functions#524

Open
utkarshpawade wants to merge 4 commits intostan-dev:masterfrom
utkarshpawade:test/theme-helper-coverage
Open

Add tests for theme/aesthetic helper functions#524
utkarshpawade wants to merge 4 commits intostan-dev:masterfrom
utkarshpawade:test/theme-helper-coverage

Conversation

@utkarshpawade
Copy link
Copy Markdown
Contributor

Fixes #523

  • Added return type checks (expect_s3_class, incomplete theme validation) for plot_bg(), panel_bg(), facet_bg(), legend_move(), legend_text()
  • Added on = FALSEelement_blank verification for all three background helpers
  • Added composition tests with real bayesplot plots (ppc_hist, ppc_dens_overlay, ppc_dens)
  • Added overlay_function return type check (LayerInstance, not theme) and plot composition
  • Added legend_move("none") equivalence with legend_none()
  • Added test for stacking multiple helpers on a single plot

Copilot AI review requested due to automatic review settings April 2, 2026 16:25
Copy link
Copy Markdown
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

Adds expanded test coverage for bayesplot theme/aesthetic convenience helpers, with checks for return types and compatibility when added to real bayesplot ggplot objects.

Changes:

  • Added tests asserting helper outputs are incomplete themes and map on = FALSE to element_blank().
  • Added composition tests ensuring helpers and overlay_function() can be added to real bayesplot plots.
  • Added a NEWS entry documenting the added tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/testthat/test-convenience-functions.R Adds new testthat cases around theme helper return types and plot composition.
NEWS.md Documents newly added tests for theme/aesthetic helpers.

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

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.15%. Comparing base (44c3e5c) to head (3e6dfd0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #524   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files          35       35           
  Lines        5920     5920           
=======================================
  Hits         5870     5870           
  Misses         50       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

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

Thanks @utkarshpawade. I think the legend_move("none") test is worth keeping, since that behavior is explicitly documented and it guards a real contract of the helper.

For the rest, I’m not convinced the added tests are giving us much benefit. Most of these helpers are very thin wrappers around ggplot2::theme() or ggplot2::stat_function(), and the existing tests already cover the main behavior by checking the returned objects directly. The new composition tests mostly confirm that ggplot can still add a valid theme/layer object to a plot, which is more ggplot behavior than bayesplot behavior. The extra on = FALSE checks also seem redundant with the existing expectations that already compare against element_blank() themes.

So my preference would be to keep the legend_move("none") test and drop the others, to avoid adding test volume without much additional protection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dedicated tests for theme/aesthetic helper functions

4 participants