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

Switch to {crul} and use {webmockr} and {vcr} for unit testing #4

Open
maelle opened this issue Jul 9, 2018 · 0 comments
Open

Switch to {crul} and use {webmockr} and {vcr} for unit testing #4

maelle opened this issue Jul 9, 2018 · 0 comments

Comments

@maelle
Copy link

maelle commented Jul 9, 2018

I see you've started adding tests, fantastic! 🎊

In the context of an API package, you'll probably want to also test the behaviour of your package when things go wrong. For instance, if the API returns an error message, your package should fail gracefully. In HIBPwned that you've mentioned in our conversation in Slack, I've used webmockr to mock the API's returning an error message, here are the corresponding tests.

The best reference about the testing of R packages interfacing web APIs is this book in progress by @sckott https://github.com/ropensci/http-testing-book It's only for packages using crul instead of httr at the moment. I'd recommend switching to crul like I did for HIBPwned but when I don't work for Locke Data I work for rOpenSci so you'll imagine I'm not subjective.

@dmi3kno dmi3kno changed the title Unit testing in the context of this package Switch to {crul} and use {webmockr} and {vcr} for unit testing Jul 9, 2018
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

1 participant