ITADN
r-lib/testthat

版本发布 7

testthat 3.2.3v3.2.3
? · 2025-01-13

* Fixed an issue where `expect_no_error(1)` was failing (#2037). * Fixed an issue where calling `skip()` outside of an active test could cause an unexpected error (@kevinushey, #2039).

testthat 3.2.2v3.2.2
? · 2024-12-10

## New expectations * `expect_s7_class()` tests if an object is an S7 class (#1580). * `expect_no_failure()`, `expect_no_success()` and `expect_snapshot_failure()` provide more options for testing expectations. ## Bug fixes and minor improvements * testthat now requires waldo 0.6.0 or later to access the latest features (#1955). * `expect_condition()` and related functions now include the `class` of the expected condition in the failure message, if provided (#1987). * `expect_error()` and friends now error if you supply `...` but not `pattern` (#1932). They no longer give an uninformative error if they fail inside a magrittr pipe (#1994). * `expect_no_*()` expectations no longer incorrectly emit a passing test result if they in fact fail (#1997). * `expect_setequal()` correctly identifies what is missing where (#1962). * `expect_snapshot()` now strips line breaks in test descriptions (@LDSamson, #1900), and errors when called from a `test_that()` that has an empty description (@kevinushey, #1980). * `expect_true()` and `expect_false()` give better errors if `actual` isn't a vector (#1996). * `expect_visible()` and `expect_invisible()` have clearer failure messages (#1966). * `local_reproducible_output()` (used in `test_that()` blocks) now sets `LANGUAGE` to `"C"` instead of `"en"` to disable translations, avoiding warnings on some platforms (#1925). * `skip_if_not_installed()` generates a clearer message that sorts better (@MichaelChirico, #1959). * `with_mock()` and `local_mock()` have been unconditionally deprecated as they will no longer work in future versions of R (#1999).

testthat 3.2.0v3.2.0
? · 2023-10-07

## Lifecycle changes * `is_informative_error()` and the `wrap` argument to `test_dir()` and friends are now defunct. * `expect_no_error()`, `expect_no_warning()`, `expect_no_message()`, `expect_no_condition()`, `local_mocked_bindings()`, and `with_mocked_bindings()` are now stable, not experimental. ## New features * All packages, regardless of whether or not they use rlang 1.0.0, now use the new snapshot display for errors, warnings, and messages (#1856). This no longer shows the class name, instead focussing on a display that more closely mimics what you'll see interactively, including showing the error call. * testthat uses an improved algorithm for finding the srcref associated with an expectation/error/warning/skip. It now looks for the most recent call that has known source and is found inside the `test_that()` call. This generally gives more specific locations than the previous approach and gives much better locations if an error occurs in an exit handler. ## Minor features and bug fixes * Helpers are no longer run twice. * `expect_setequal()` correctly displays results when only one of actual and expected is missing elements (#1835). * `expect_snapshot()` and friends no longer create a temporary file on every invocation. * `expect_snapshot_file()` now generates clickable links to review changes (#1821). * `expect_snapshot_value()` has an improved error if the object can't be safely serialized using the specified `style` (#1771). * `options(rlang_interactive = TRUE)` no longer causes `skip_on_cran()` to not run on CRAN (#1868). * `skip_if_offline()` now errors if you don't have curl installed (#1854). * `StopReporter` gains the ability to suppress praise when a test passes. * `ProgressReporter` now uses is a two characters wide skip column in order to have a consistent width when 10 or more tests are skipped in a single file (@mgirlich, #1844). * `test_file()` gains a `desc` argument which allows you to run a single test from a file (#1776).

testthat 3.1.10v3.1.10
? · 2023-07-07

* Fix for upcoming R-devel release. * `testthat` now sets the `_R_CHECK_BROWSER_NONINTERACTIVE_` environment variable when running tests. This should ensure that left-over `browser()` statements will trigger an error if encountered while running tests. This functionality is only enabled with R (>= 4.3.0). (#1825)

testthat 3.1.9v3.1.9
? · 2023-06-16

* New `expect_contains()` and `expect_in()` that works similarly to `expect_true(all(expected %in% object))` or `expect_true(all(object %in% expected))` but give more informative failure messages (#1346). * New `is_snapshot()` returns `TRUE` if code is running inside a snapshot test (#1796) and `is_checking()` returns `TRUE` if test is running inside of `R CMD check` (#1795) * `ProgressReporter` only reports the run time of test files that take longer than 1s, rather than 0.1s. (#1806) and re-displays all failures at the end of the results. Skips are now only shown at the end of reporter summaries, not as tests are run. This makes them less intrusive in interactive tests while still allowing you to verify that the correct tests are skipped (#1801). When using parallel tests, links to failed tests (#1787) and links to accept/review snapshot (#1802) now work. * `set_state_inspector()` allows to to register a function that's called before and after every test, reporting on any differences. This is very useful for detecting if any of your tests have made changes to global state (like options, env vars, or connections) (#1674). This function was inspired by renv's testing infrastructure. * `skip_on_cran()` no longer skips (errors) when run interactively. * `teardown_env()` works in more cases. * All packages, regardless of whether or not they use rlang, now use the new snapshot display for errors, warnings, and messages. * testthat no longer truncates tracebacks and uses rlang's default tree display.

testthat 3.1.8v3.1.8
? · 2023-05-04

* `expect_snapshot()` differences no longer use quotes. * `expect_error()`, `expect_warning()`, and `expect_message()` now correctly enforce that the condition is of the expected base class (e.g. error, warning, messsage) even when the `class` argument is used (#1168). * `it()` now calls `local_test_context()` so that it behaves more similarly to `test_that()` (#1731), and is now exported so that you can more easily run BDD tests interactively (#1587) * `skip_on_bioc()` now uses the documented environment variable (`IS_BIOC_BUILD_MACHINE`) (#1712). * `source_file()`, which is used by various parts of the helper and setup/teardown machinery, now reports the file name in the case of errors (#1704). * `test_path()` now works when called within helper files (#1562). * New `vignette("special-files")` describes the various special files that testthat uses (#1638). * `with_mocked_bindings()` and `local_mocked_bindings()` now also bind in the imports namespace and can mock S3 methods. These changes make them good substitutes for the deprecated functions `with_mock()` and `local_mock()`, so those older functions now recommend switching to the newer equivalents instead of using the mockr or mockery packages.

testthat 3.1.7v3.1.7
? · 2023-03-12

* `expect_setequal()` gives more actionable feedback (#1657). * `expect_snapshot()` no longer elides new lines when run interactively (#1726). * Experimental new `with_mocked_bindings()` and `local_mocked_bindings()` (#1739).