generateUnitTestFile {wyz.code.testthat} | R Documentation |
Generate Testthat Unit Test File
Description
Generate one testthat
unit test file from an instrumented offensive
programming object. One test file per function is created. It holds all the
related tests, organized by evaluation mode.
See EvaluationMode
for more information.
Usage
generateUnitTestFile(filename_s_1, content_s,
overwrite_b_1 = FALSE,
verbose_b_1 = TRUE)
Arguments
filename_s_1 |
the name of the unit test file to generate |
content_s |
the content of the unit test file to generate |
overwrite_b_1 |
A boolean value, either |
verbose_b_1 |
A boolean value, either |
Value
Returns the file name.
It might be different from the one provided, as
testthat
requires to follow some file naming conventions that are enforced by this function.
Note
This function is provided for convenience. It may ease your own way to generate
testthat
code.
To put this package in action, simply use gautfo
that offers a much more straightforward way to get results.
Author(s)
Fabien Gelineau <neonira@gmail.com>
Maintainer: Fabien Gelineau <neonira@gmail.com>
References
Refer to test_file
from package
testthat
.
Refer to runTestCase
from package wyz.code.offensiveProgramming
.
Examples
##---- typical example ----
fn <- file.path(tempdir(), 'myFile')
fr <- generateUnitTestFile(fn, c("# a comment", "x <- 2"))
cat(paste(readLines(fr$filename), collapse = '\n'))
# a comment
# x <- 2