There's been a request for a fail function in testthat, that just makes a test fail.
http://stackoverflow.com/questions/12507229/how-to-make-a-test-fail-with-the-testthat-package
I had a go at writing one, for possible inclusion in the package.
' Makes a testfail
'
' The fail function forces a test to fail.
'
' @PARAM message a string to display.
' @PARAM infoextra information to be included in the message (useful when writing tests in loops).
fail <- function(message = "Failure has been forced.", info = NULL)
{
expect_that(
NULL,
function(message)
{
expectation(FALSE, message)
},
info = info,
NULL
)
}
Usage is, for example,
test_that("failure test", fail())
There's been a request for a
failfunction intestthat, that just makes a test fail.http://stackoverflow.com/questions/12507229/how-to-make-a-test-fail-with-the-testthat-package
I had a go at writing one, for possible inclusion in the package.
' Makes a testfail
'
' The fail function forces a test to fail.
'
' @PARAM message a string to display.
' @PARAM infoextra information to be included in the message (useful when writing tests in loops).
fail <- function(message = "Failure has been forced.", info = NULL)
{
expect_that(
NULL,
function(message)
{
expectation(FALSE, message)
},
info = info,
NULL
)
}
Usage is, for example,