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

Best practice for vcr-enabled tests on CRAN #102

Closed
dpprdan opened this issue Jun 25, 2019 · 5 comments
Closed

Best practice for vcr-enabled tests on CRAN #102

dpprdan opened this issue Jun 25, 2019 · 5 comments
Milestone

Comments

@dpprdan
Copy link
Member

dpprdan commented Jun 25, 2019

I've started using {vcr} for the tests in {opencage}, but I am unsure, what the best practices are regarding running the tests on CRAN (or not).

I have seen that some of the tests that use vcr in other packages skip_on_cran(), but not all, e.g. https://github.com/ropensci/worrms/blob/master/tests/testthat/test-wm_children.R

So it seems to be possible to run these tests on CRAN? Is there anything one has to keep in mind? E.g. where should the cassettes ideally go (for {opencage} I stored them in tests/vcr_cassettes)?

@dpprdan
Copy link
Member Author

dpprdan commented Jun 25, 2019

I guess one (obvious?) thing to keep in mind would be to create the cassettes by running e.g. devtools::test().

@sckott
Copy link
Collaborator

sckott commented Jun 25, 2019

Yes, it is possible to run tests on CRAN that use cassettes on disk. I think at first when vcr was just on CRAN I was skipping tests that used vcr until I was sure it worked on CRAN checks, but it should be fine now to run tests that use vcr on CRAN

I don't know the scope of what's allowed for running tests on CRAN - but it has worked to have them in tests/ somewhere. I've used tests/vcr_cassettes and tests/fixtures/vcr_cassettes

One thing to note is that if you have your cassettes in .gitignore then your cassetttes won't be pushed up to github and tests wouldn't have access to them in remote locations. I think Adam Sparks had done this.

wrt using devtools::test() first: i'll play around with that and have a look - but I'd guess that yes, one would need to run that first if check() uses a tempdir

@dpprdan
Copy link
Member Author

dpprdan commented Jun 26, 2019

Thanks! We're all set then, it seems. 🎉

One thing to note is that if you have your cassettes in .gitignore then your cassetttes won't be pushed up to github and tests wouldn't have access to them in remote locations.

The same applies to .Rbuildignore, I suppose.

Do you want to add "vcr-enabled tests on CRAN" to the docs/README/HTTP-testing-book?

@sckott
Copy link
Collaborator

sckott commented Jun 26, 2019

right, same-ish for .Rbuildignore

Do you want to add "vcr-enabled tests on CRAN" to the docs/README/HTTP-testing-book?

sure, what exactly are you thinking? e.g., how can this section https://github.com/ropensci/vcr#vcr-for-tests be improved

sckott added a commit to ropensci-books/http-testing that referenced this issue Jun 28, 2019
@sckott sckott added this to the v0.3 milestone Jun 28, 2019
@sckott
Copy link
Collaborator

sckott commented Jun 28, 2019

@sckott sckott closed this as completed Jun 28, 2019
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

No branches or pull requests

2 participants