-
Notifications
You must be signed in to change notification settings - Fork 340
Closed
Description
I recently encountered a test file with a structure like this:
test_that(
desc = "no error",
code = expect_no_error(
{1 + 1}
)
)When I test this file, it warns about code run outside of test_that(), as expected:
> devtools:::test_active_file()
[ FAIL 0 | WARN 2 | SKIP 0 | PASS 6 ]
ββ Warning (test-autoplot.summary.seroincidence.by.R:108:1): (code run outside of `test_that()`) ββββββ
The `code` argument to `test_that()` must be a braced expression to get accurate file-line information for failures.
Backtrace:
β
1. ββtestthat::test_that(...) at test-autoplot.summary.seroincidence.by.R:108:1
ββ Warning (test-autoplot.summary.seroincidence.by.R:145:1): (code run outside of `test_that()`) ββββββ
The `code` argument to `test_that()` must be a braced expression to get accurate file-line information for failures.
Backtrace:
β
1. ββtestthat::test_that(...) at test-autoplot.summary.seroincidence.by.R:145:1
[ FAIL 0 | WARN 2 | SKIP 0 | PASS 6 ]
However, when I run devtools::check(error_on = "warning") on the package containing this test, devtools::check() doesn't seem to count the testthat warning as real, even when I set test_check("[packagename]", stop_on_warning = TRUE) in testthat.R:
ββ R CMD check results βββββββββββββββββββββββββββββββββββββββββββββββββ
Duration: 2m 20.3s
0 errors β | 0 warnings β | 0 notes β
I wrote a new test in a fork of testthat as a reprex: #2069
Is this behavior as-intended?
Metadata
Metadata
Assignees
Labels
No labels