You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## About This Project
6
+
7
+
testthat is R's most popular unit testing framework, used by thousands of CRAN packages. It provides functions to make testing R code as fun and addictive as possible, with clear expectations, visual progress indicators, and seamless integration with R package development workflows.
8
+
9
+
## Key Development Commands
10
+
11
+
General advice:
12
+
* When running R from the console, always run it with `--quiet --vanilla`
13
+
* Always run `air format .` after generating code
14
+
15
+
### Development tools
16
+
17
+
-`devtools::test()` - Run all tests
18
+
-`devtools::test_file("tests/testthat/test-filename.R")` - Run tests in a specific file
19
+
-`devtools::load_all()` - Load package for development
-`Config/testthat/start-first` - Tests to run first in parallel mode
74
+
75
+
### C++ Testing Infrastructure
76
+
77
+
testthat provides C++ testing capabilities via Catch framework:
78
+
- Headers in `inst/include/testthat/`
79
+
- Test runner infrastructure in `src/test-runner.cpp`
80
+
- Integration with R's testing system
81
+
82
+
### Snapshot Testing Workflow
83
+
84
+
- Snapshots stored in `tests/testthat/_snaps/`
85
+
- Different snapshot types: values, files, output
86
+
- Version-specific snapshots for different R versions
87
+
- Use `testthat::snapshot_accept()` to update snapshots
88
+
89
+
This codebase prioritizes backward compatibility, comprehensive testing, and clear, descriptive error messages to help R developers write better tests.
Copy file name to clipboardExpand all lines: NEWS.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,27 @@
1
1
# testthat (development version)
2
2
3
+
*`expect_*()` functions consistently and rigorously check their inputs (#1754).
4
+
*`JunitReporter()` no longer fails with `"no applicable method for xml_add_child"` for warnings outside of tests (#1913). Additionally, warnings now save their backtraces.
5
+
*`JunitReporter()` strips ANSI escapes in more placese (#1852, #2032).
6
+
*`try_again()` is now publicised. The first argument is now the number of retries, not tries (#2050).
7
+
*`vignette("custom-expectations)` has been overhauled to make it much clearer how to create high-quality expectations (#2113, #2132, #2072).
8
+
*`expect_snapshot()` and friends will now fail when creating a new snapshot on CI. This is usually a signal that you've forgotten to run it locally before committing (#1461).
9
+
*`expect_snapshot_value()` can now handle expressions that generate `-` (#1678) or zero length atomic vectors (#2042).
10
+
*`expect_matches()` failures should be a little easier to read (#2135).
11
+
* New `local_on_cran(TRUE)` allows you to simulate how your tests will run on CRAN (#2112).
12
+
*`expect_no_*()` now executes the entire code block, rather than stopping at the first message or warning (#1991).
13
+
*`expect_no_failures()` and `expect_no_successes()` are now deprecated as `expect_success()` now test for no failures and `expect_failure()` tests for no successes (#)
14
+
* New `pass()` function to use in place of `succeed()` (#2113).
15
+
*`expectation()` is now a combination of `new_expectation()` and `exp_signal()` (#2125).
16
+
*`is_null()`/`matches()` deprecated in 2.0.0 (2017-12-19) and `is_true()`/`is_false()` deprecated in 2.1.0 (2019-04-23) have been removed (#2109).
17
+
*`local_edition()` now gives a useful error for bad values (#1547).
3
18
* testthat now requires R 4.1.
4
19
*`expect_s4_class()` now supports unquoting (@stibu81, #2064).
5
20
*`it()` now finds the correct evaluation environment in more cases (@averissimo, #2085).
6
21
* Fixed an issue preventing compilation from succeeding due to deprecation / removal of `std::uncaught_exception()` (@kevinushey, #2047).
7
22
* New `skip_unless_r()` to skip running tests on unsuitable versions of R, e.g. `skip_unless_r(">= 4.1.0")` to skip tests that require, say, `...names` (@MichaelChirico, #2022)
8
23
*`skip_on_os()` gains an option `"emscripten"` of the `os` argument to skip tests on Emscripten (@eitsupi, #2103).
24
+
* New expectation, `expect_shape()`, for testing the shape (i.e., the `length()`, `nrow()`, `ncol()`, or `dim()`), all in one place (#1423, @michaelchirico).
0 commit comments