Skip to content

Commit

Permalink
test_file(desc =) now also finds describe() tests (#1904)
Browse files Browse the repository at this point in the history
Fixes #1903
  • Loading branch information
hadley authored Nov 28, 2023
1 parent 5659da8 commit 3400834
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# testthat (development version)

* `test_file(desc = )` will now find `describe()` tests as well as `testthat()`
tests (#1903).

* `JunitReporter()` now uses ensures numeric values are saved the xml file
with `.` as decimal separator. (@maksymiuks, #1660)

Expand Down
2 changes: 1 addition & 1 deletion R/source.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ filter_desc <- function(exprs, desc = NULL, error_call = caller_env()) {
for (i in seq_along(exprs)) {
expr <- exprs[[i]]

if (!is_call(expr, "test_that", n = 2)) {
if (!is_call(expr, c("test_that", "describe"), n = 2)) {
if (!found) {
include[[i]] <- TRUE
}
Expand Down
2 changes: 1 addition & 1 deletion R/test-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test_dir <- function(path,
#' @param path Path to file.
#' @param ... Additional parameters passed on to `test_dir()`
#' @param desc Optionally, supply a string here to run only a single
#' test that has this `desc`ription.
#' test (`test_that()` or `describe()`) with this `desc`ription.
#' @export
#' @examples
#' path <- testthat_example("success")
Expand Down
2 changes: 1 addition & 1 deletion man/test_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-source.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test_that("can find only matching test", {
f(),
test_that("foo", {}),
g(),
test_that("bar", {}),
describe("bar", {}),
h()
)
expect_equal(filter_desc(code, "foo"), code[c(1, 2)])
Expand Down

0 comments on commit 3400834

Please sign in to comment.