Basics |
|
|---|---|
Run a test |
|
Do you expect this value? |
|
|
|
Do you expect an error, warning, message, or other condition? |
Do you expect |
|
Expectations |
|
Values |
|
Do you expect every value in a vector to have this value? |
|
Do you expect a value bigger or smaller than this? |
|
Do you expect an object with this length or shape? |
|
Do you expect a string to match this pattern? |
|
Do you expect a vector with (these) names? |
|
Do you expect |
|
|
|
Do you expect a vector containing these values? |
|
|
Do you expect an S3/S4/R6/S7 object that inherits from this class? |
Do you expect a vector with this size and/or prototype? |
|
Side-effects |
|
|
|
Do you expect the absence of errors, warnings, messages, or other conditions? |
Do you expect the result to be (in)visible? |
|
Do you expect printed output to match this pattern? |
|
Do you expect code to execute silently? |
|
Snapshot tests |
|
Do you expect this code to run the same way as last time? |
|
Do you expect this code to return the same value as last time? |
|
|
|
Do you expect this code to create the same file as last time? |
Accept or reject modified snapshots |
|
Download snapshots from GitHub |
|
Test helpers |
|
|
|
Determine testing status |
Extract a reprex from a failed expectation |
|
Temporarily change the active testthat edition |
|
Temporarily set options for maximum reproducibility |
|
Check for global state changes |
|
|
|
Skip a test for various reasons |
Run code after all test files |
|
Evaluate an expectation multiple times until it succeeds |
|
Run tests |
|
Run all tests in a directory |
|
Run tests in a single file |
|
Run all tests in a package |
|
Locate a file in the testing directory |
|
Use Catch for C++ unit testing |
|
Mocking |
|
Temporarily redefine function definitions |
|
Mock S3 and S4 methods |
|
Mock an R6 class |
|
Mock a sequence of output from a function |
|
Custom expectations |
|
Declare that an expectation either passes or fails |
|
|
|
Test your custom expectations |
Reporters |
|
Report results for |
|
Interactively debug failing tests |
|
Fail if any tests fail |
|
Report results in jUnit XML format |
|
Capture test results and metadata |
|
Test reporter: location |
|
Report minimal results as compactly as possible |
|
Run multiple reporters at the same time |
|
|
|
Report progress interactively |
Report results to RStudio |
|
Silently collect and all expectations |
|
Find slow tests |
|
Error if any test fails |
|
Report a summary of failures |
|
Report results in TAP format |
|
Report results in Teamcity format |
|