10.6 Documentation and code coverage
10.6.1 Vignette
Long format documentation
Rmd-first prototyping method
Either in
inst/
orvignettes/
devtools::build_vignettes()
10.6.2 Code coverage and Continuous Integration
Code coverage
- Assess which lines in your code are covered by the tests in
tests/
usethis::use_coverage()
({covr})- Test coverage may be greater, if you have puppeteer / selenium tests
covr::package_coverage()
- Assess which lines in your code are covered by the tests in
Test the important stuff, and test it well
Coverage metrics are easily gamed
Think about:
- branch-coverage, not lines-covered
- will the tests be affected by internal restructuring
- would restructuring make it easier to test something that currently isn’t covered?
Continuous Integration
- eg, for running tests every time you check in code to GitHub
- Providers: GitHub Actions, GitLab CI, Circle CI, Jenkins, Travis CI
usethis::use_github_action
- prewritten actions for tests, linting, pkgdown …