Learn R Programming

runittotestthat (version 0.0-2)

convert_test: Convert an RUnit test to a testthat test

Description

Converts a single RUnit test to a testthat test.

Usage

convert_test(runit_test_fn, test_description = assertive::get_name_in_parent(runit_test_fn))

Arguments

runit_test_fn
An RUnit test function.
test_description
A string describing the test, defaulting to the name of the RUnit test function.

Value

A call to test_that, containing a testhat test equivalent to the input RUnit test.

See Also

convert_package_tests, convert_test_file

Examples

Run this code
test_truth <- function()
{
  x <- all(runif(10) > 0)
  checkTrue(x)
}
convert_test(test_truth)
test_equality <- function()
{
  x <- sqrt(1:5)
  expected <- c(1, 4, 9, 16, 25)
  checkEquals(expected, x ^ 4)
}
convert_test(test_equality)
test_error <- function()
{
  checkException("1" + "2")
}
convert_test(test_error)

Run the code above in your browser using DataLab