tests/testthat/test-examples.R

test_that("test_examples works with installed packages", {
  local_edition(2)

  local_mock(test_rd = identity)
  expect_true(length(test_examples()) > 1)
})

test_that("test_examples fails if no examples", {
  withr::local_envvar(TESTTHAT_PKG = "")
  expect_error(test_examples("asdf"), "Could not find examples")
})

Try the testthat package in your browser

Any scripts or data that you put into this service are public.

testthat documentation built on Jan. 21, 2022, 1:10 a.m.