Learn R Programming

testex (version 0.2.1)

testex-testthat: Support for testthat Expectations

Description

testthat support is managed through a "style" provided to testex. When using the testthat style (automatically when using the @testthat tag), expectations are processed such that they always refer to the previous example. Special care is taken to manage propagation of this value through your test code, regardless of how testthat is executed.

Arguments

Examples

Run this code
# example code
1 + 2

# within `testex` block, test code refers to previous result with `.`
testex(style = "testthat", srcref = "abc.R:1:3", { # \dontshow{
  . <- 3 # needed because roxygen2 @examplesIf mutates .Last.value
  # }
  test_that("addition holds up", {
    expect_equal(., 3)
  })
})

Run the code above in your browser using DataLab