Skip to content

Testing in R #155

@robchallen

Description

@robchallen

Since you are advocating for writing functions it is worth talking about the @examples tag in Roxygen blocks. These allow functional tests to be documented within the function man page and are a requirement for CRAN submission (interestingly testthat tests are not).

You can run all the examples with devtools::run_examples() and the examples all get run on RCMD check and they form a key part of the documentation of a function. If you build a pkgdown site all the results of the examples are run and shown in the site.

They are very useful for iterative testing whilst developing a function as they can be executed direct from the RStudio code editor as you are working on a function.

They don't show up as code coverage and can only run on exported functions from your package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    peer reviewFeedback from peer review of the repo

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions