Description Usage Value Author(s) Examples
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.
1 |
A complete roclet.
Bryan A. Hanson
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.