This roclet automates the creation of unit tests, using
written in the function definition files, and processed using
The unit tests are written verbatim to the appropriate destination file.
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.