ttm_expect_error: Test that multi: expect error

View source: R/expect_error.R

ttm_expect_errorR Documentation

Test that multi: expect error

Description

See 'testthat::expect_error' for details.

Usage

ttm_expect_error(object, info = NULL, label = NULL, verbose = 0)

Arguments

object

Object to test.

info

Passed to 'testthat::expect_error()'.

label

Passed to 'testthat::expect_error()'.

verbose

Amount of info that should be printed.

Value

Test result

Examples

set.seed(0)

# 1 attempt, all pass
ttm(1, {
  ttm_expect_error(stop('error'))
})

# Fails first ~10 times, then passes
ttm(100, {
  ttm_expect_error({
    print(1)
    if (runif(1) < 0.1) {
      stop('give error')
    }
  })
})

# Will always fail regardless of number of attempts
try({
  ttm(3, {
    ttm_expect_error(1 == 2)
  })
})

testthatmulti documentation built on Aug. 25, 2025, 1:10 a.m.