runittotestthat v0.0-2


Monthly downloads



Convert 'RUnit' Test Functions into 'testthat' Tests

Automatically convert a file or package worth of 'RUnit' test functions into 'testthat' tests.



Convert RUnit tests to testthat tests.


To install, you first need the devtools package.


Then you can install the runittotestthat package using


Converting tests

There are three functions of interest:

  1. convert_test converts an individual RUnit test to a call to a testthat test.

     test_truth <- function()
       x <- all(runif(10) > 0)
     ## test_that("test_truth", {
     ##     x <- all(runif(10) > 0)
     ##     expect_true(x)
     ## })
     test_equality <- function()
       x <- sqrt(1:5)
       expected <- c(1, 4, 9, 16, 25)
       checkEquals(expected, x ^ 4)
     ## test_that("test_equality", {
     ##     x <- sqrt(1:5)
     ##     expected <- c(1, 4, 9, 16, 25)
     ##     expect_equal(x^4, expected)
     ## })
     test_error <- function()
       checkException("1" + "2")
     ## test_that("test_error", {
     ##     expect_error("1" + "2")
     ## })
  2. convert_test_file sources all the tests in a file, converts each one, then outputs them to a file (or file connection; stdout by default).

  3. convert_package_tests takes a string naming a package, or a devtools::package object and loops over the files in inst/tests (or wherever you specify), converting the tests, and outputting to files or stdout.

Functions in runittotestthat

Name Description
convert_checkIdentical Convert a checkIdentical call.
convert_repeat Convert a repeat block.
convert_if Convert an if block.
convert_brace Convert a code block.
convert_package_tests Convert a package worth of RUnit tests to testthat tests
get_filename Get a quoted filename
convert_lines Convert lines of RUnit code to testthat code
convert_line Convert lines of RUnit code to testthat code
convert_checkTrue Convert a checkTrue call.
convert_switch Convert a switch block.
runittotestthat Convert RUnit tests to testthat tests.
convert_for Convert a for block.
convert_checkEqualsNumeric Convert a checkEqualsNumeric call.
convert_checkEquals Convert a checkEquals call.
convert_while Convert a while block.
convert_test Convert an RUnit test to a testthat test
convert_checkException Convert a checkException call.
convert_test_file Convert a file worth of RUnit tests to testthat tests
No Results!

Last month downloads


Type Package
Date 2015-06-24
License Unlimited
LazyLoad yes
LazyData yes
Acknowledgments Development of this package was partially funded by the Proteomics Core at Weill Cornell Medical College in Qatar . The Core is supported by 'Biomedical Research Program' funds, a program funded by Qatar Foundation.
NeedsCompilation no
Packaged 2015-06-24 13:35:37 UTC; rjc2003
Repository CRAN
Date/Publication 2015-06-24 15:45:01

Include our badge in your README