Skip to content

expect_no_error() reports both PASS and FAIL (when it actually should only FAIL) #1997

@dheimgartner

Description

@dheimgartner

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorconditions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions