testthat

一个用于测试的 R 包。「An R 📦 to make testing 😀」

Github星跟踪图

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("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.

主要指标

概览
名称与所有者r-lib/testthat
主编程语言R
编程语言R (语言数: 4)
平台Linux, Mac, Windows
许可证Other
所有者活动
创建于2009-09-02 12:51:44
推送于2025-09-05 14:35:10
最后一次提交
发布数43
最新版本名称v3.2.3 (发布于 )
第一版名称testthat-0.1 (发布于 2009-11-17 19:07:21)
用户参与
星数0.9k
关注者数19
派生数335
提交数2.5k
已启用问题?
问题数1405
打开的问题数5
拉请求数635
打开的拉请求数1
关闭的拉请求数177
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?