Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need better framework for testing expectations #368

hadley opened this issue Feb 19, 2016 · 0 comments

Need better framework for testing expectations #368

hadley opened this issue Feb 19, 2016 · 0 comments


Copy link

hadley commented Feb 19, 2016



f <- function() NULL
g <- function() cat("!")

test_that("expect = NA checks for no output", {
  expect_error(expect_output(f(), NA), NA)
  expect_error(expect_output(g(), NA), "produced output")

test_that("expect = NULL checks for some output", {
  expect_error(expect_output(f(), NULL), "didn't produce output")
  expect_error(expect_output(g(), NULL), NA)

test_that("expect = string checks for match", {
  expect_error(expect_output(g(), "!"), NA)
  expect_error(expect_output(g(), "x"), "does not match 'x'")

And each expectation needs its own test file.

hadley added a commit that referenced this issue Feb 19, 2016
@hadley hadley closed this as completed in 42b9d1e Feb 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant