tests/testthat/test-reporter.R

test_that("can control output with file arg/option", {
  # powered through Reporter base class so we only test one reporter
  path <- tempfile()
  withr::defer(unlink(path))

  with_reporter(
    MinimalReporter$new(file = path),
    test_one_file(test_path("reporters/tests.R"))
  )
  expect_snapshot_output(readLines(path))

  withr::local_options(testthat.output_file = path)
  with_reporter(
    MinimalReporter$new(),
    test_one_file(test_path("reporters/tests.R"))
  )
  expect_snapshot_output(readLines(path))
})

test_that("should not automatically skip in non-utf-8 locales", {
  withr::local_locale(LC_CTYPE = "C")
  expect_true(TRUE)
})

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.