testthat
testthat copied to clipboard
`expect_no_error()` reports both PASS and FAIL (when it actually should only FAIL)
The following test
test_that("should intentionally fail", {
erroneous_function <- function() {
stop("I am an errouneous function!")
}
expect_no_error(erroneous_function())
})
produces the following output
> devtools::test()
ℹ Testing testingBug
✔ | F W S OK | Context
✖ | 1 1 | example
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Failure (test-example.R:3:5): should intentionally fail
Expected `erroneous_function()` to run without any errors.
i Actually got a <simpleError> with text:
I am an errouneous function!
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
══ Results ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
── Failed tests ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Failure (test-example.R:3:5): should intentionally fail
Expected `erroneous_function()` to run without any errors.
i Actually got a <simpleError> with text:
I am an errouneous function!
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 1 ]
Why does it report OK 1 and PASS 1 when the only test actually fails (it produces an error)?
Hmmm, weird. Even simpler reprex:
test_that("should intentionally fail", {
expect_no_error(foo())
})