Skip to content
An R 📦 to make testing 😀
Branch: master
Clone or download
Latest commit c7d3dc0 Jul 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Mod CODEOWNERS to stop auto-request (#774) Jul 9, 2018
R Improve summary report readability (#903) Jul 17, 2019
inst silence -Wcatch-value warnings Apr 22, 2019
man Add exact argument to expect_s3_class Jul 16, 2019
pkgdown/favicon Build pkgdown site automatically Apr 17, 2019
revdep Re-run failed test and summarise for CRAN Apr 18, 2019
src Use local labelling instead of rlang equiv Oct 16, 2017
tests Improve summary report readability (#903) Jul 17, 2019
vignettes More expectation object tidying/refactoring Apr 2, 2019
.Rbuildignore use_mit_license() Jul 18, 2019
.covrignore use_tidy_ci() Mar 28, 2019
.gitattributes update .gitattributes Nov 10, 2015
.gitignore Build pkgdown site automatically Apr 17, 2019
.travis.yml Make serialization version 2 the default (#900) Jul 15, 2019
DESCRIPTION Add missing "to" in DESCRIPTION (#894) Jul 15, 2019
LICENSE use_mit_license() Jul 18, 2019
LICENSE.md use_mit_license() Jul 18, 2019
NAMESPACE Implement expect_mapequal() Apr 17, 2019
NEWS.md Autotest should treat helpers as code, not tests (#897) Jul 17, 2019
README.Rmd Add new appveyor badge Apr 1, 2019
README.md Add new appveyor badge Apr 1, 2019
_pkgdown.yml Add google analytics Jun 25, 2019
appveyor.yml Junit reporter (#481) Dec 19, 2016
codecov.yml Use tidy CI Oct 2, 2017
cran-comments.md Prepare for patch release Apr 23, 2019
testthat.Rproj Recognise for testInstallPackages directory structure Dec 16, 2016

README.md

testthat

CRAN status Travis build status AppVeyor Build Status 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("devtools")
devtools::install_github("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.

You can’t perform that action at this time.