Movatterモバイル変換


[0]ホーム

URL:


testthat

CRAN statusR-CMD-checkCodecov test coverage

Overview

Testing your code can be painful and tedious, but it greatlyincreases the quality of your code.testthat tries tomake testing as fun as possible, so that you get a visceral satisfactionfrom writing tests. Testing should be addictive, so you do it all thetime. To make that happen, testthat:

testthat draws inspiration from the xUnit family of testing packages,as well as from many of the innovative ruby testing libraries, likerspec,testy,bacon andcucumber.

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

If you’re not familiar with testthat, thetesting chapter inR packages gives a good overview, alongwith workflow advice and concrete examples.

Installation

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

Usage

The easiest way to get started is withusethis. Assuming you’re ina package directory, just runusethis::use_test("name") tocreate a test file, and set up all the other infrastructure you need. Ifyou’re using RStudio, press Cmd/Ctrl + Shift + T (or rundevtools::test() if not) to run all the tests in apackage.


[8]ページ先頭

©2009-2025 Movatter.jp