tests/testthat/test-expect-silent.R

test_that("checks for any type of output", {
  expect_failure(expect_silent(warning("!")))
  expect_failure(expect_silent(message("!")))
  expect_failure(expect_silent(print("!")))

  expect_success(expect_silent(""))
})

test_that("returns first argument", {
  expect_equal(expect_silent(1), 1)
})
r-lib/testthat documentation built on Aug. 9, 2019, 1:50 p.m.