test_fun: Run test attached to function

View source: R/test-fun.R

test_funR Documentation

Run test attached to function

Description

Execute test attached to a function with testthat::Reporter.

Usage

test_fun(object, reporter = testthat::MinimalReporter)

Arguments

object

to which the test is attached

reporter

testthat::Reporter to use

Value

the test (function)

Examples


f <- function(x) x^2

test(f) <- function() {
   context("f")

   test_that("correct result for complex number", {
     expect_equal(f(1i), -1 + 0i)
   })
}

test_fun(f)

hySpc.testthat documentation built on Dec. 22, 2025, 5:07 p.m.