tests_roclet: tests_roclet

Description Usage Value Author(s) Examples

View source: R/tests_roclet.R

Description

This roclet automates the creation of unit tests, using @tests tags written in the function definition files, and processed using roxygen2. The unit tests are written verbatim to the appropriate destination file.

Usage

1

Value

A complete roclet.

Author(s)

Bryan A. Hanson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# In actual use, the test lines would be in your function definition file.
# The results (cat'd here) would be written to the unit test file.
# If the function definition file is myFunc.R then the results
# are written to test-myFunc.R in the appropriate directory
# (the directory depends on whether your are using tinytest or testthat).

tinytest_in <- "#' @tests tinytest\n#' # Are these equal?\n#' expect_equal(5.0, 5.0)\nNULL\n"
tinytest_out <- roxygen2::roc_proc_text(tests_roclet(), tinytest_in)
cat(tinytest_out$tinytest, "\n")

testthat_in <- "#' @tests testthat\n#' # Are these equal?\n#' expect_equal(5.0, 5.0)\nNULL\n"
testthat_out <- roxygen2::roc_proc_text(tests_roclet(), testthat_in)
cat(testthat_out$testthat, "\n")

roxut documentation built on Aug. 23, 2021, 1:10 a.m.