Skip to content
/ testthat Public

An R ๐Ÿ“ฆ to make testing ๐Ÿ˜€

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

r-lib/testthat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

30f5b11 ยท Feb 28, 2025
Oct 22, 2024
Feb 28, 2025
Aug 15, 2024
Feb 28, 2025
Apr 17, 2019
Nov 7, 2024
Jun 17, 2020
Feb 28, 2025
Aug 23, 2024
Apr 1, 2022
Mar 28, 2019
Nov 10, 2015
Jul 22, 2019
Feb 28, 2025
Mar 21, 2023
Mar 21, 2023
Feb 28, 2025
Feb 24, 2025
Oct 22, 2024
Oct 22, 2024
Feb 28, 2025
Apr 13, 2020
Jan 10, 2025
Aug 24, 2022

Repository files navigation

testthat

CRAN status R-CMD-check Codecov test coverage

Overview

Testing your code can be painful and tedious, but it greatly increases the quality of your code. testthat tries to make testing as fun as possible, so that you get a visceral satisfaction from writing tests. Testing should be addictive, so you do it all the time. To make that happen, testthat:

  • Provides functions that make it easy to describe what you expect a function to do, including catching errors, warnings, and messages.

  • Easily integrates in your existing workflow, whether itโ€™s informal testing on the command line, building test suites, or using R CMD check.

  • Displays test progress visually, showing a pass, fail, or error for every expectation. If youโ€™re using the terminal or a recent version of RStudio, itโ€™ll even colour the output.

testthat draws inspiration from the xUnit family of testing packages, as well as from many of the innovative ruby testing libraries, like rspec, testy, bacon and cucumber.

testthat is the most popular unit testing package for R and is used by thousands of CRAN packages.

If youโ€™re not familiar with testthat, the testing chapter in R packages gives a good overview, along with workflow advice and concrete examples.

Installation

# Install the released version from CRAN
install.packages("testthat")

# Or the development version from GitHub:
# install.packages("pak")
pak::pak("r-lib/testthat")

Usage

The easiest way to get started is with usethis. Assuming youโ€™re in a package directory, just run usethis::use_test("name") to create a test file, and set up all the other infrastructure you need. If youโ€™re using RStudio, press Cmd/Ctrl + Shift + T (or run devtools::test() if not) to run all the tests in a package.

About

An R ๐Ÿ“ฆ to make testing ๐Ÿ˜€

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Citation

Stars

Watchers

Forks

Languages