Unit Testing for R
Watches code and tests for changes, rerunning tests as appropriate.
Capture conditions, including messages, warnings, expectations, and er...
Capture output to console
Report results for R CMD check
Compare two directory states.
Provide human-readable comparison of two objects
Do you expect a value bigger or smaller than this?
Start test context from a file name
Describe the context of a set of tests.
Interactively debug failing tests
Retrieve the default reporter
describe: a BDD testing language
Capture the state of a directory.
Do you expect this value?
Evaluate a promise, capturing all types of output.
Do you expect every value in a vector to have this value?
Is an object equal to the expected value, ignoring attributes?
Do you expect an error, warning, message, or other condition?
Do you expect the result to be (in)visible?
Do you expect to inherit from this class?
Do you expect the results/output to equal a known value?
Do you expect an object with this length or shape?
Deprecated numeric comparison functions
Do you expect a string to match this pattern?
Do you expect a vector with (these) names?
Do you expect the absence of errors, warnings, messages, or other cond...
Test for absence of success or failure
Do you expect NULL?
Do you expect the output/result to equal a known good value?
Do you expect printed output to match this pattern?
Do you expect a reference to this object?
Do you expect a vector containing these values?
Do you expect code to execute silently?
Do you expect this code to create the same file as last time?
Snapshot helpers
Do you expect this code to return the same value as last time?
Do you expect this code to run the same way as last time?
Test your custom expectations
Expect that a condition holds.
Do you expect a vector with this size and/or prototype?
The previous building block of all expect_ functions
Expectation conditions
Extract a reprex from a failed expectation
Declare that an expectation either passes or fails
Fail if any tests fail
Find reporter object given name or object.
Find test files
Do you expect an S3/S4/R6/S7 object that inherits from this class?
Is an error informative?
Determine testing status
Report results in jUnit XML format
Capture test results and metadata
Temporarily change the active testthat edition
Temporarily redefine function definitions
Mock an R6 class
Mock S3 and S4 methods
Instantiate local snapshotting context
Temporarily set options for maximum reproducibility
Locally set test directory options
Test reporter: location
Do you expect TRUE or FALSE?
Make an equality test.
Report minimal results as compactly as possible
Mock a sequence of output from a function
Run multiple reporters at the same time
Negate an expectation
Old-style expectations.
Report progress interactively
Quasi-labelling
Objects exported from other packages
Get and set active reporter.
Manage test reporting
Report results to RStudio
Do C++ tests past?
Set maximum number of test failures allowed before aborting the run
Check for global state changes
Silently collect and all expectations
Superseded skip functions
Skip a test for various reasons
Find slow tests
Accept or reject modified snapshots
Download snapshots from GitHub
Source a file, directory of files, or various important subsets
Error if any test fails
Mark a test as successful
Report a summary of failures
Does code take less than the expected amount of time to run?
Report results in TAP format
Report results in Teamcity format
Run code after all test files
Run code before/after tests
Run all tests in a directory
Generate default testing environment.
Test package examples
Run tests in a single file
Run all tests in a package
Locate a file in the testing directory
Run a test
Retrieve paths to built-in example test files
Create a testthat_results object from the test results as stored in ...
Default numeric tolerance
An R package to make testing fun!
Simulate a test environment
Evaluate an expectation multiple times until it succeeds
Use Catch for C++ unit testing
Verify output
Watch a directory for changes (additions, deletions & modifications).
Mock functions in a package.
Software testing is important, but, in part because it is frustrating and boring, many of us avoid it. 'testthat' is a testing framework for R that is easy to learn and use, and integrates with your existing 'workflow'.
Useful links