tests/testthat/test-test-env.R

test_that("environment has package name", {
  expect_equal(methods::getPackageName(test_env("testthat")), "testthat")
  expect_equal(methods::getPackageName(topenv()), "testthat")
})

setClass("MyClass")
test_that("Cannot create S4 class without special behaviour", {
  expect_error(setClass("MyClass2"), NA)
})

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.