tests/testthat/test_dir/test-basic.R

test_that("logical tests act as expected", {
  expect_true(TRUE)
  expect_false(FALSE)
})

test_that("logical tests ignore attributes", {
  expect_true(c(a = TRUE))
  expect_false(c(a = FALSE))
})

test_that("equality holds", {
  expect_equal(5, 5)
  expect_identical(10, 10)
})

test_that("can't access variables from other tests 2", {
  a <- 10
})

test_that("can't access variables from other tests 1", {
  expect_false(exists("a"))
})

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.