Skip to content

Commit 3400834

Browse files
authored
test_file(desc =) now also finds describe() tests (#1904)
Fixes #1903
1 parent 5659da8 commit 3400834

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# testthat (development version)
22

3+
* `test_file(desc = )` will now find `describe()` tests as well as `testthat()`
4+
tests (#1903).
5+
36
* `JunitReporter()` now uses ensures numeric values are saved the xml file
47
with `.` as decimal separator. (@maksymiuks, #1660)
58

R/source.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ filter_desc <- function(exprs, desc = NULL, error_call = caller_env()) {
7171
for (i in seq_along(exprs)) {
7272
expr <- exprs[[i]]
7373

74-
if (!is_call(expr, "test_that", n = 2)) {
74+
if (!is_call(expr, c("test_that", "describe"), n = 2)) {
7575
if (!found) {
7676
include[[i]] <- TRUE
7777
}

R/test-files.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test_dir <- function(path,
109109
#' @param path Path to file.
110110
#' @param ... Additional parameters passed on to `test_dir()`
111111
#' @param desc Optionally, supply a string here to run only a single
112-
#' test that has this `desc`ription.
112+
#' test (`test_that()` or `describe()`) with this `desc`ription.
113113
#' @export
114114
#' @examples
115115
#' path <- testthat_example("success")

man/test_file.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-source.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test_that("can find only matching test", {
5454
f(),
5555
test_that("foo", {}),
5656
g(),
57-
test_that("bar", {}),
57+
describe("bar", {}),
5858
h()
5959
)
6060
expect_equal(filter_desc(code, "foo"), code[c(1, 2)])

0 commit comments

Comments
 (0)