Documentation examples and tests are similar in some ways:

This similarity makes it attractive to use "doctests", which combine tests and documentation. Indeed, several languages, including Python and Rust, have doctests built in.^1 R also checks for errors in examples when running R CMD check.

https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html

The doctest package extends this idea. It lets you write testthat tests, by adding tags to your roxygen documentation. This helps you check that your examples do what they are supposed to do.



Try the doctest package in your browser

Any scripts or data that you put into this service are public.

doctest documentation built on May 29, 2024, 7:09 a.m.