local_testthat: Unit test helpers

local_testthatR Documentation

Unit test helpers

Description

Local helper functions for package unit tests

Usage

local_fm_testthat_assign(x, values, envir = parent.frame())

local_fm_testthat_tolerances(
  tolerances = c(1e-04, 0.01, 0.1),
  envir = parent.frame()
)

local_fm_testthat_setup(envir = parent.frame())

Arguments

x

character; Name of variable to assign to

values

the object to assign to x

envir

environment for exit handlers

tolerances

numeric vector of length 3; ⁠[lowtol, midtol, hitol]⁠

Value

None

Functions

  • local_fm_testthat_assign(): Assign local variable. Useful for easy cleanup of global workspace with withr::deferred_run() when running tests interactively.

  • local_fm_testthat_tolerances(): Assign test tolerances Assign local tolerance variables. Useful for easy cleanup of global workspace with withr::deferred_run() when running tests interactively.

  • local_fm_testthat_setup(): Initialise environment for tests. To be called either at the top of a testfile, or inside tests.

Examples

outer_fun <- function() {
  fun <- function(envir = parent.frame()) {
    local_fm_testthat_assign("local_var_name", 1:4, envir = envir)
  }
  fun()
  local_var_name
}
exists("local_var_name")
outer_fun()
exists("local_var_name")


fmesher documentation built on July 1, 2024, 5:07 p.m.