get_test {hySpc.testthat}R Documentation

Get test that is attached to object as "test" attribute

Description

The returned function can be executed. If that is done within a testthat::Reporter, the results will be reported accordingly. Without reporter, the test runs silently if successful and stops if it fails.

Usage

get_test(object)

Arguments

object

to which the test is attached

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)
   })
}

get_test(f)

library(testthat)
## execute the test
get_test(f)()

with_reporter("summary", get_test(f)())

[Package hySpc.testthat version 0.2.1 Index]