-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.Rmd
47 lines (38 loc) · 2.8 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: "HTTP testing in R"
date: "`r Sys.Date()`"
author: "Scott Chamberlain, Maëlle Salmon"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
github-repo: ropensci-books/http-testing
description: "Best practice and tips for testing packages interfacing web resources."
url: 'https\://books.ropensci.org/http-testing/'
---
<a href="https://doi.org/10.5281/zenodo.10608848"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.10608848.svg" alt="DOI"></a>
# Preamble
Are you working on an R package accessing resources on the web, be it a cat facts API, a scientific data source or your system for Customer relationship management?
As with all other packages, appropriate unit testing can make your code more robust.
The unit testing of a package interacting with web resources, however, brings special challenges:
dependence of tests on a good internet connection, testing in the absence of authentication secrets, etc.
Having tests fail due to resources being down or slow, during development or on CRAN, means a time loss for everyone involved (slower development, messages from CRAN).
Although some packages accessing remote resources are well tested, there is a lack of resources around best practices.
This book is meant to be a free, central reference for developers of R packages accessing web resources, to help them have a faster and more robust development.
Our aim is to develop a useful guide to go with the great recent tools `{vcr}`, `{webmockr}`, `{httptest}`, `{httptest2}` and `{webfakes}`.
We expect you to know [package development basics](https://r-pkgs.org/), and [git](https://happygitwithr.com/).
_Note related to previous versions: this book was intended as a detailed guide to using a particular suite of packages for HTTP mocking and testing in R code and/or packages, namely those maintained by Scott Chamberlain (`{crul}`, `{webmockr}`, `{vcr}`), but its scope has been extended to generalize the explanation of concepts to similar packages._
You can also read the [PDF version](/http-testing/main.pdf) or [epub version](/http-testing/main.epub) of this book.
_Thanks to contributors to the book:
[Alex Whan](https://github.com/alexwhan),
[Aurèle](https://github.com/eaurele),
[Christophe Dervieux](https://github.com/cderv),
[Daniel Possenriede](https://github.com/dpprdan),
[Hugo Gruson](https://github.com/Bisaloo),
[Jon Harmon](https://github.com/jonthegeek/),
[Lluís Revilla Sancho](https://github.com/llrs),
[Xavier A](https://github.com/xvrdm)._
```{block, type = "alert alert-dismissible alert-success"}
Project funded by [rOpenSci](https://ropensci.org) (Scott Chamberlain's work) & the [R Consortium](https://www.r-consortium.org/projects/awarded-projects/2020-group-1#HTTP+testing+in+R+Book) (Maëlle Salmon's work).
```