Skip to content

expect_error() does not find errors that occur after expectations #618

Closed
@maxheld83

Description

@maxheld83

I'm using checkmate expect_*() to run (input) validation for my functions in some package.
If I want to test these validations in turn, using testthat, the usual expect_error() does fails, even when the expression does in fact error out as it should.

MWE from @mllg:

context("nested expect")

foo = function(x) {
  expect_true(x)
  stop("myerror")
}

test_that("nested expect", {
  expect_error(foo("a"), "myerror")
})

Issue was originally raised over at checkmate in mllg/checkmate#82.
@mllg suspected it might be a testthat issue.

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