You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 @sckotthttps://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.
The text was updated successfully, but these errors were encountered:
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 usedwebmockr
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 ofhttr
at the moment. I'd recommend switching tocrul
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.The text was updated successfully, but these errors were encountered: