tests/testthat/test-reporter-stop.R

test_that("produces useful output", {
  expect_snapshot_reporter(StopReporter$new())
})

test_that("stop if needed errors when needed",{
  r <- StopReporter$new()
  expect_error(r$stop_if_needed(), NA)
  r$n_fail <- 1
  expect_error(r$stop_if_needed(), "Test failed")
  r$stop_reporter <- FALSE
  expect_error(r$stop_if_needed(), 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.