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

Refactor tests to use snapshots and abort_bad_argument() #50

Merged
merged 5 commits into from
Jul 1, 2024
Merged

Refactor tests to use snapshots and abort_bad_argument() #50

merged 5 commits into from
Jul 1, 2024

Conversation

olivroy
Copy link
Contributor

@olivroy olivroy commented Jun 28, 2024

Here are a couple extra suggestions when trying to improve error messages.

I highly recommend using snapshot tests, as you can quickly verify that your output changed how you want it.

It is better to add a call argument to abort_bad_argument() to make testing easier

expect_snapshot(error = TRUE) is a lifesaver https://testthat.r-lib.org/articles/snapshotting.html

Also discovered that abort() / cli_abort() have a dedicated argument to take care of extra info: footer, so renamed it to this (and if custom, don't show footer)

custom requires must to be optional.

Edit: made a mistake in the first place that I easily caught with snapshot tests! e8d8868 It is easier to experiment this way

@olivroy olivroy changed the title Cli follow Refactor tests to use snapshots and abort_bad_argument() Jun 28, 2024
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (66a84ec) to head (e8d8868).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #50   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          287       286    -1     
=========================================
- Hits           287       286    -1     

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

@wjakethompson
Copy link
Owner

This great--thank you!!

@wjakethompson wjakethompson merged commit 2c4cd58 into wjakethompson:main Jul 1, 2024
10 checks passed
@olivroy olivroy deleted the cli-follow branch July 1, 2024 22:19
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.

2 participants