-
Notifications
You must be signed in to change notification settings - Fork 20
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
Wrapping an expectation inside a function #48
Comments
Hi Jon, This is an interesting feature, and I think it has to be implemented in |
I've added it in 32571b7, version 1.1.0.3 It would be great if you could give it a whirl. Be aware that See |
Many thanks Mark – this looks good. I don't think the write restrictions will be a problem in practice (for me at least), because I would always regenerate the reference files before building the package, so they would already exist at the time of running |
Cheers Jon, I'm going to close this now. Feel free to reopen or submit another issue if you find any issues. |
For anyone looking here because they want to do "Wrapping an expectation inside a function" and wondering if there is some easier way besides getting the function merged into source("<HELPERFILE.R>", local = TRUE) at the top of the test file. (The fact that it doesn't work without |
Thanks @mb706. Indeed trying to use custom expectation functions for package testing. Which is the appropriate folder for "<HELPERFILE.R>" ? |
@MartinBeal The working directory for package tests will generally be |
I have a package whose tests need updating, so I thought it would be good chance to try porting them over to
tinytest
and give it a test-drive. Everything looks great, except for the fact that this package generates some relatively complex outputs that I have previously tested with theexpect_equal_to_reference
expectation which I previously contributed totestthat
. It doesn't exist intinytest
, but I assumed I could relatively easily get it working by wrapping existing expectations, viz.and then sourcing the file containing this function at the top of each test file. But it doesn't do anything – these expectations seem to be silently ignored.
If I understand the discussion in issue #22 properly, this is probably because of how expectation functions are specially evaluated within the testing loop. But creating a formal extension and registering it with
register_tinytest_extension
feels like overkill sinceexpect_equivalent
basically already does the right thing. But perhaps I'm thinking about it the wrong way. Is there a way to get this sort of "semi-custom" expectation working, or should I approach it differently?Thanks in advance. I really like
tinytest
's sleekness!The text was updated successfully, but these errors were encountered: