Description Usage Arguments Value Note See Also Examples
Converts all RUnit tests in a file to testthat tests, and writes them out to another file.
1 2 | convert_test_file(runit_file, test_func_regexp = "^test.+",
testthat_file = stdout())
|
runit_file |
A path to an file containing |
test_func_regexp |
Regular expression determining which functions in the tests files are considered to be tests. |
testthat_file |
String of path for the output file.
Defaults to |
A list of calls to test_that
is invisibly returned. This list
is also written to an output connection (defaulting to stdout).
An environment containing the original RUnit
is stored in
attr(, "runit_tests")
.
RUnit
tests will be evaluated when they are read in, so make
sure that all your tests pass before you convert them.
The testthat_file
argument can be based upon the runit_file
argument. For example, if you use the traditional RUnit
test file
naming strategy, something like sub("^runit", "testthat", runit_file)
may be appropriate.
convert_package_tests
, convert_test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | tmp <- tempfile("test-convert_test_file")
writeLines(
"test_truth <- function()
{
x <- all(runif(10) > 0)
checkTrue(x)
}
test_equality <- function()
{
x <- sqrt(1:5)
expected <- c(1, 4, 9, 16, 25)
checkEquals(expected, x ^ 4)
}
test_error <- function()
{
checkException('1' + '2')
}",
tmp
)
convert_test_file(tmp)
unlink(tmp)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.